home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Modules / almodule.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  80.2 KB  |  3,388 lines

  1. #define OLD_INTERFACE        /* define for pre-Irix 6 interface */
  2.  
  3. #include "Python.h"
  4. #include "stringobject.h"
  5. #include <audio.h>
  6. #include <stdarg.h>
  7.  
  8. #ifndef AL_NO_ELEM
  9. #ifndef OLD_INTERFACE
  10. #define OLD_INTERFACE
  11. #endif /* OLD_INTERFACE */
  12. #endif /* AL_NO_ELEM */
  13.  
  14. static PyObject *ErrorObject;
  15.  
  16. /* ----------------------------------------------------- */
  17.  
  18. /* Declarations for objects of type port */
  19.  
  20. typedef struct {
  21.     PyObject_HEAD
  22.     /* XXXX Add your own stuff here */
  23.     ALport port;
  24. } alpobject;
  25.  
  26. staticforward PyTypeObject Alptype;
  27.  
  28.  
  29.  
  30. /* ---------------------------------------------------------------- */
  31.  
  32. /* Declarations for objects of type config */
  33.  
  34. typedef struct {
  35.     PyObject_HEAD
  36.     /* XXXX Add your own stuff here */
  37.     ALconfig config;
  38. } alcobject;
  39.  
  40. staticforward PyTypeObject Alctype;
  41.  
  42.  
  43. static void
  44. ErrorHandler(long code, const char *fmt, ...)
  45. {
  46.     va_list args;
  47.     char buf[128];
  48.  
  49.     va_start(args, fmt);
  50.     vsprintf(buf, fmt, args);
  51.     va_end(args);
  52.     PyErr_SetString(ErrorObject, buf);
  53. }
  54.  
  55. #ifdef AL_NO_ELEM        /* IRIX 6 */
  56.  
  57. static PyObject *
  58. param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo)
  59. {
  60.     ALparamInfo info;
  61.     PyObject *v;
  62.  
  63.     if (pinfo == NULL) {
  64.         pinfo = &info;
  65.         if (alGetParamInfo(resource, param, &info) < 0)
  66.             return NULL;
  67.     }
  68.     switch (pinfo->elementType) {
  69.     case AL_PTR_ELEM:
  70.         /* XXXX don't know how to handle this */
  71.     case AL_NO_ELEM:
  72.         Py_INCREF(Py_None);
  73.         return Py_None;
  74.     case AL_INT32_ELEM:
  75.     case AL_RESOURCE_ELEM:
  76.     case AL_ENUM_ELEM:
  77.         return PyInt_FromLong((long) value.i);
  78.     case AL_INT64_ELEM:
  79.         return PyLong_FromLongLong(value.ll);
  80.     case AL_FIXED_ELEM:
  81.         return PyFloat_FromDouble(alFixedToDouble(value.ll));
  82.     case AL_CHAR_ELEM:
  83.         if (value.ptr == NULL) {
  84.             Py_INCREF(Py_None);
  85.             return Py_None;
  86.         }
  87.         return PyString_FromString((char *) value.ptr);
  88.     default:
  89.         PyErr_SetString(ErrorObject, "unknown element type");
  90.         return NULL;
  91.     }
  92. }
  93.  
  94. static int
  95. python2elem(PyObject *item, void *ptr, int elementType)
  96. {
  97.     switch (elementType) {
  98.     case AL_INT32_ELEM:
  99.     case AL_RESOURCE_ELEM:
  100.     case AL_ENUM_ELEM:
  101.         if (!PyInt_Check(item)) {
  102.             PyErr_BadArgument();
  103.             return -1;
  104.         }
  105.         *((int *) ptr) = PyInt_AsLong(item);
  106.         break;
  107.     case AL_INT64_ELEM:
  108.         if (PyInt_Check(item))
  109.             *((long long *) ptr) = PyInt_AsLong(item);
  110.         else if (PyLong_Check(item))
  111.             *((long long *) ptr) = PyLong_AsLongLong(item);
  112.         else {
  113.             PyErr_BadArgument();
  114.             return -1;
  115.         }
  116.         break;
  117.     case AL_FIXED_ELEM:
  118.         if (PyInt_Check(item))
  119.             *((long long *) ptr) = alDoubleToFixed((double) PyInt_AsLong(item));
  120.         else if (PyFloat_Check(item))
  121.             *((long long *) ptr) = alDoubleToFixed(PyFloat_AsDouble(item));
  122.         else {
  123.             PyErr_BadArgument();
  124.             return -1;
  125.         }
  126.         break;
  127.     default:
  128.         PyErr_SetString(ErrorObject, "unknown element type");
  129.         return -1;
  130.     }
  131.     return 0;
  132. }
  133.  
  134. static int
  135. python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo)
  136. {
  137.     ALparamInfo info;
  138.     int i, stepsize;
  139.     PyObject *item;
  140.  
  141.     if (pinfo == NULL) {
  142.         pinfo = &info;
  143.         if (alGetParamInfo(resource, param->param, &info) < 0)
  144.             return -1;
  145.     }
  146.     switch (pinfo->valueType) {
  147.     case AL_STRING_VAL:
  148.         if (pinfo->elementType != AL_CHAR_ELEM) {
  149.             PyErr_SetString(ErrorObject, "unknown element type");
  150.             return -1;
  151.         }
  152.         if (!PyString_Check(value)) {
  153.             PyErr_BadArgument();
  154.             return -1;
  155.         }
  156.         param->value.ptr = PyString_AS_STRING(value);
  157.         param->sizeIn = PyString_GET_SIZE(value)+1; /*account for NUL*/
  158.         break;
  159.     case AL_SET_VAL:
  160.     case AL_VECTOR_VAL:
  161.         if (!PyList_Check(value) && !PyTuple_Check(value)) {
  162.             PyErr_BadArgument();
  163.             return -1;
  164.         }
  165.         switch (pinfo->elementType) {
  166.         case AL_INT32_ELEM:
  167.         case AL_RESOURCE_ELEM:
  168.         case AL_ENUM_ELEM:
  169.             param->sizeIn = PySequence_Length(value);
  170.             param->value.ptr = PyMem_NEW(int, param->sizeIn);
  171.             stepsize = sizeof(int);
  172.             break;
  173.         case AL_INT64_ELEM:
  174.         case AL_FIXED_ELEM:
  175.             param->sizeIn = PySequence_Length(value);
  176.             param->value.ptr = PyMem_NEW(long long, param->sizeIn);
  177.             stepsize = sizeof(long long);
  178.             break;
  179.         }
  180.         for (i = 0; i < param->sizeIn; i++) {
  181.             item = PySequence_GetItem(value, i);
  182.             if (python2elem(item, (void *) ((char *) param->value.ptr + i*stepsize), pinfo->elementType) < 0) {
  183.                 PyMem_DEL(param->value.ptr);
  184.                 return -1;
  185.             }
  186.         }
  187.         break;
  188.     case AL_SCALAR_VAL:
  189.         switch (pinfo->elementType) {
  190.         case AL_INT32_ELEM:
  191.         case AL_RESOURCE_ELEM:
  192.         case AL_ENUM_ELEM:
  193.             return python2elem(value, (void *) ¶m->value.i,
  194.                        pinfo->elementType);
  195.         case AL_INT64_ELEM:
  196.         case AL_FIXED_ELEM:
  197.             return python2elem(value, (void *) ¶m->value.ll,
  198.                        pinfo->elementType);
  199.         default:
  200.             PyErr_SetString(ErrorObject, "unknown element type");
  201.             return -1;
  202.         }
  203.     }
  204.     return 0;
  205. }
  206.  
  207. static int
  208. python2params(int resource1, int resource2, PyObject *list, ALpv **pvsp, ALparamInfo **pinfop)
  209. {
  210.     PyObject *item;
  211.     ALpv *pvs;
  212.     ALparamInfo *pinfo;
  213.     int npvs, i;
  214.  
  215.     npvs = PyList_Size(list);
  216.     pvs = PyMem_NEW(ALpv, npvs);
  217.     pinfo = PyMem_NEW(ALparamInfo, npvs);
  218.     for (i = 0; i < npvs; i++) {
  219.         item = PyList_GetItem(list, i);
  220.         if (!PyArg_ParseTuple(item, "iO", &pvs[i].param, &item))
  221.             goto error;
  222.         if (alGetParamInfo(resource1, pvs[i].param, &pinfo[i]) < 0 &&
  223.             alGetParamInfo(resource2, pvs[i].param, &pinfo[i]) < 0)
  224.             goto error;
  225.         if (python2param(resource1, &pvs[i], item, &pinfo[i]) < 0)
  226.             goto error;
  227.     }
  228.  
  229.     *pvsp = pvs;
  230.     *pinfop = pinfo;
  231.     return npvs;
  232.  
  233.   error:
  234.     /* XXXX we should clean up everything */
  235.     if (pvs)
  236.         PyMem_DEL(pvs);
  237.     if (pinfo)
  238.         PyMem_DEL(pinfo);
  239.     return -1;
  240. }
  241.  
  242. /* -------------------------------------------------------- */
  243.  
  244.  
  245. static PyObject *
  246. SetConfig(self, args, func)
  247.     alcobject *self;
  248.     PyObject *args;
  249.     int (*func)(ALconfig, int);
  250. {
  251.     int par;
  252.  
  253.     if (!PyArg_ParseTuple(args, "i:SetConfig", &par))
  254.         return NULL;
  255.  
  256.     if ((*func)(self->config, par) == -1)
  257.         return NULL;
  258.  
  259.     Py_INCREF(Py_None);
  260.     return Py_None;
  261. }
  262.  
  263. static PyObject *
  264. GetConfig(self, args, func)
  265.     alcobject *self;
  266.     PyObject *args;
  267.     int (*func)(ALconfig);
  268. {    
  269.     int par;
  270.  
  271.     if (!PyArg_ParseTuple(args, ":GetConfig"))
  272.         return NULL;
  273.     
  274.     if ((par = (*func)(self->config)) == -1)
  275.         return NULL;
  276.  
  277.     return PyInt_FromLong((long) par);
  278. }
  279.  
  280. static char alc_SetWidth__doc__[] = 
  281. "alSetWidth: set the wordsize for integer audio data."
  282. ;
  283.  
  284. static PyObject *
  285. alc_SetWidth(self, args)
  286.     alcobject *self;
  287.     PyObject *args;
  288. {
  289.     return SetConfig(self, args, alSetWidth);
  290. }
  291.  
  292.  
  293. static char alc_GetWidth__doc__[] = 
  294. "alGetWidth: get the wordsize for integer audio data."
  295. ;
  296.  
  297. static PyObject *
  298. alc_GetWidth(self, args)
  299.     alcobject *self;
  300.     PyObject *args;
  301. {
  302.     return GetConfig(self, args, alGetWidth);
  303. }
  304.  
  305.  
  306. static char alc_SetSampFmt__doc__[] = 
  307. "alSetSampFmt: set the sample format setting in an audio ALconfig structure."
  308. ;
  309.  
  310. static PyObject *
  311. alc_SetSampFmt(self, args)
  312.     alcobject *self;
  313.     PyObject *args;
  314. {
  315.     return SetConfig(self, args, alSetSampFmt);
  316. }
  317.  
  318.  
  319. static char alc_GetSampFmt__doc__[] = 
  320. "alGetSampFmt: get the sample format setting in an audio ALconfig structure."
  321. ;
  322.  
  323. static PyObject *
  324. alc_GetSampFmt(self, args)
  325.     alcobject *self;
  326.     PyObject *args;
  327. {
  328.     return GetConfig(self, args, alGetSampFmt);
  329. }
  330.  
  331.  
  332. static char alc_SetChannels__doc__[] = 
  333. "alSetChannels: set the channel settings in an audio ALconfig."
  334. ;
  335.  
  336. static PyObject *
  337. alc_SetChannels(self, args)
  338.     alcobject *self;
  339.     PyObject *args;
  340. {
  341.     return SetConfig(self, args, alSetChannels);
  342. }
  343.  
  344.  
  345. static char alc_GetChannels__doc__[] = 
  346. "alGetChannels: get the channel settings in an audio ALconfig."
  347. ;
  348.  
  349. static PyObject *
  350. alc_GetChannels(self, args)
  351.     alcobject *self;
  352.     PyObject *args;
  353. {
  354.     return GetConfig(self, args, alGetChannels);
  355. }
  356.  
  357.  
  358. static char alc_SetFloatMax__doc__[] = 
  359. "alSetFloatMax: set the maximum value of floating point sample data."
  360. ;
  361.  
  362. static PyObject *
  363. alc_SetFloatMax(self, args)
  364.     alcobject *self;
  365.     PyObject *args;
  366. {
  367.     double maximum_value;
  368.  
  369.     if (!PyArg_ParseTuple(args, "d:SetFloatMax", &maximum_value))
  370.         return NULL;
  371.     if (alSetFloatMax(self->config, maximum_value) < 0)
  372.         return NULL;
  373.     Py_INCREF(Py_None);
  374.     return Py_None;
  375. }
  376.  
  377.  
  378. static char alc_GetFloatMax__doc__[] = 
  379. "alGetFloatMax: get the maximum value of floating point sample data."
  380. ;
  381.  
  382. static PyObject *
  383. alc_GetFloatMax(self, args)
  384.     alcobject *self;
  385.     PyObject *args;
  386. {
  387.     double maximum_value;
  388.  
  389.     if (!PyArg_ParseTuple(args, ":GetFloatMax"))
  390.         return NULL;
  391.     if ((maximum_value = alGetFloatMax(self->config)) == 0)
  392.         return NULL;
  393.     return PyFloat_FromDouble(maximum_value);
  394. }
  395.  
  396.  
  397. static char alc_SetDevice__doc__[] = 
  398. "alSetDevice: set the device setting in an audio ALconfig structure."
  399. ;
  400.  
  401. static PyObject *
  402. alc_SetDevice(self, args)
  403.     alcobject *self;
  404.     PyObject *args;
  405. {
  406.     return SetConfig(self, args, alSetDevice);
  407. }
  408.  
  409.  
  410. static char alc_GetDevice__doc__[] = 
  411. "alGetDevice: get the device setting in an audio ALconfig structure."
  412. ;
  413.  
  414. static PyObject *
  415. alc_GetDevice(self, args)
  416.     alcobject *self;
  417.     PyObject *args;
  418. {
  419.     return GetConfig(self, args, alGetDevice);
  420. }
  421.  
  422.  
  423. static char alc_SetQueueSize__doc__[] = 
  424. "alSetQueueSize: set audio port buffer size."
  425. ;
  426.  
  427. static PyObject *
  428. alc_SetQueueSize(self, args)
  429.     alcobject *self;
  430.     PyObject *args;
  431. {
  432.     return SetConfig(self, args, alSetQueueSize);
  433. }
  434.  
  435.  
  436. static char alc_GetQueueSize__doc__[] = 
  437. "alGetQueueSize: get audio port buffer size."
  438. ;
  439.  
  440. static PyObject *
  441. alc_GetQueueSize(self, args)
  442.     alcobject *self;
  443.     PyObject *args;
  444. {
  445.     return GetConfig(self, args, alGetQueueSize);
  446. }
  447.  
  448. #endif /* AL_NO_ELEM */
  449.  
  450. static PyObject *
  451. setconfig(self, args, func)
  452.     alcobject *self;
  453.     PyObject *args;
  454.     int (*func)(ALconfig, long);
  455. {
  456.     long par;
  457.  
  458.     if (!PyArg_ParseTuple(args, "l:SetConfig", &par))
  459.         return NULL;
  460.  
  461.     if ((*func)(self->config, par) == -1)
  462.         return NULL;
  463.  
  464.     Py_INCREF(Py_None);
  465.     return Py_None;
  466. }
  467.  
  468. static PyObject *
  469. getconfig(self, args, func)
  470.     alcobject *self;
  471.     PyObject *args;
  472.     long (*func)(ALconfig);
  473. {    
  474.     long par;
  475.  
  476.     if (!PyArg_ParseTuple(args, ":GetConfig"))
  477.         return NULL;
  478.     
  479.     if ((par = (*func)(self->config)) == -1)
  480.         return NULL;
  481.  
  482.     return PyInt_FromLong((long) par);
  483. }
  484.  
  485. static PyObject *
  486. alc_setqueuesize (self, args)
  487.     alcobject *self;
  488.     PyObject *args;
  489. {
  490.     return setconfig(self, args, ALsetqueuesize);
  491. }
  492.  
  493. static PyObject *
  494. alc_getqueuesize (self, args)
  495.     alcobject *self;
  496.     PyObject *args;
  497. {
  498.     return getconfig(self, args, ALgetqueuesize);
  499. }
  500.  
  501. static PyObject *
  502. alc_setwidth (self, args)
  503.     alcobject *self;
  504.     PyObject *args;
  505. {
  506.     return setconfig(self, args, ALsetwidth);
  507. }
  508.  
  509. static PyObject *
  510. alc_getwidth (self, args)
  511.     alcobject *self;
  512.     PyObject *args;
  513. {
  514.     return getconfig(self, args, ALgetwidth);    
  515. }
  516.  
  517. static PyObject *
  518. alc_getchannels (self, args)
  519.     alcobject *self;
  520.     PyObject *args;
  521. {
  522.     return getconfig(self, args, ALgetchannels);    
  523. }
  524.  
  525. static PyObject *
  526. alc_setchannels (self, args)
  527.     alcobject *self;
  528.     PyObject *args;
  529. {
  530.     return setconfig(self, args, ALsetchannels);
  531. }
  532.  
  533. #ifdef AL_405
  534.  
  535. static PyObject *
  536. alc_getsampfmt (self, args)
  537.     alcobject *self;
  538.     PyObject *args;
  539. {
  540.     return getconfig(self, args, ALgetsampfmt);    
  541. }
  542.  
  543. static PyObject *
  544. alc_setsampfmt (self, args)
  545.     alcobject *self;
  546.     PyObject *args;
  547. {
  548.     return setconfig(self, args, ALsetsampfmt);
  549. }
  550.  
  551. static PyObject *
  552. alc_getfloatmax(self, args)
  553.     alcobject *self;
  554.     PyObject *args;
  555. {
  556.     double arg;
  557.  
  558.     if (!PyArg_ParseTuple(args, ":GetFloatMax"))
  559.         return 0;
  560.     if ((arg = ALgetfloatmax(self->config)) == 0)
  561.         return NULL;
  562.     return PyFloat_FromDouble(arg);
  563. }
  564.  
  565. static PyObject *
  566. alc_setfloatmax(self, args)
  567.     alcobject *self;
  568.     PyObject *args;
  569. {
  570.     double arg;
  571.  
  572.     if (!PyArg_ParseTuple(args, "d:SetFloatMax", &arg))
  573.         return 0;
  574.     if (ALsetfloatmax(self->config, arg) == -1)
  575.         return NULL;
  576.     Py_INCREF(Py_None);
  577.     return Py_None;
  578. }
  579. #endif /* AL_405 */
  580.     
  581. static struct PyMethodDef alc_methods[] = {
  582. #ifdef AL_NO_ELEM        /* IRIX 6 */
  583.     {"SetWidth",    (PyCFunction)alc_SetWidth,    METH_VARARGS,    alc_SetWidth__doc__},
  584.     {"GetWidth",    (PyCFunction)alc_GetWidth,    METH_VARARGS,    alc_GetWidth__doc__},
  585.     {"SetSampFmt",    (PyCFunction)alc_SetSampFmt,    METH_VARARGS,    alc_SetSampFmt__doc__},
  586.     {"GetSampFmt",    (PyCFunction)alc_GetSampFmt,    METH_VARARGS,    alc_GetSampFmt__doc__},
  587.     {"SetChannels",    (PyCFunction)alc_SetChannels,    METH_VARARGS,    alc_SetChannels__doc__},
  588.     {"GetChannels",    (PyCFunction)alc_GetChannels,    METH_VARARGS,    alc_GetChannels__doc__},
  589.     {"SetFloatMax",    (PyCFunction)alc_SetFloatMax,    METH_VARARGS,    alc_SetFloatMax__doc__},
  590.     {"GetFloatMax",    (PyCFunction)alc_GetFloatMax,    METH_VARARGS,    alc_GetFloatMax__doc__},
  591.     {"SetDevice",    (PyCFunction)alc_SetDevice,    METH_VARARGS,    alc_SetDevice__doc__},
  592.     {"GetDevice",    (PyCFunction)alc_GetDevice,    METH_VARARGS,    alc_GetDevice__doc__},
  593.     {"SetQueueSize",    (PyCFunction)alc_SetQueueSize,    METH_VARARGS,    alc_SetQueueSize__doc__},
  594.     {"GetQueueSize",    (PyCFunction)alc_GetQueueSize,    METH_VARARGS,    alc_GetQueueSize__doc__},
  595. #endif /* AL_NO_ELEM */
  596.     {"getqueuesize",    (PyCFunction)alc_getqueuesize,    METH_VARARGS},
  597.     {"setqueuesize",    (PyCFunction)alc_setqueuesize,    METH_VARARGS},
  598.     {"getwidth",        (PyCFunction)alc_getwidth,    METH_VARARGS},
  599.     {"setwidth",        (PyCFunction)alc_setwidth,    METH_VARARGS},
  600.     {"getchannels",        (PyCFunction)alc_getchannels,    METH_VARARGS},
  601.     {"setchannels",        (PyCFunction)alc_setchannels,    METH_VARARGS},
  602. #ifdef AL_405
  603.     {"getsampfmt",        (PyCFunction)alc_getsampfmt,    METH_VARARGS},
  604.     {"setsampfmt",        (PyCFunction)alc_setsampfmt,    METH_VARARGS},
  605.     {"getfloatmax",        (PyCFunction)alc_getfloatmax,    METH_VARARGS},
  606.     {"setfloatmax",        (PyCFunction)alc_setfloatmax,    METH_VARARGS},
  607. #endif /* AL_405 */
  608.  
  609.     {NULL,        NULL}        /* sentinel */
  610. };
  611.  
  612. /* ---------- */
  613.  
  614.  
  615. static PyObject *
  616. newalcobject(ALconfig config)
  617. {
  618.     alcobject *self;
  619.     
  620.     self = PyObject_New(alcobject, &Alctype);
  621.     if (self == NULL)
  622.         return NULL;
  623.     /* XXXX Add your own initializers here */
  624.     self->config = config;
  625.     return (PyObject *) self;
  626. }
  627.  
  628.  
  629. static void
  630. alc_dealloc(self)
  631.     alcobject *self;
  632. {
  633.     /* XXXX Add your own cleanup code here */
  634. #ifdef AL_NO_ELEM        /* IRIX 6 */
  635.     (void) alFreeConfig(self->config);    /* ignore errors */
  636. #else
  637.     (void) ALfreeconfig(self->config);    /* ignore errors */
  638. #endif
  639.     PyObject_Del(self);
  640. }
  641.  
  642. static PyObject *
  643. alc_getattr(self, name)
  644.     alcobject *self;
  645.     char *name;
  646. {
  647.     /* XXXX Add your own getattr code here */
  648.     return Py_FindMethod(alc_methods, (PyObject *)self, name);
  649. }
  650.  
  651. static char Alctype__doc__[] = 
  652. ""
  653. ;
  654.  
  655. static PyTypeObject Alctype = {
  656.     PyObject_HEAD_INIT(&PyType_Type)
  657.     0,                /*ob_size*/
  658.     "config",            /*tp_name*/
  659.     sizeof(alcobject),        /*tp_basicsize*/
  660.     0,                /*tp_itemsize*/
  661.     /* methods */
  662.     (destructor)alc_dealloc,    /*tp_dealloc*/
  663.     (printfunc)0,        /*tp_print*/
  664.     (getattrfunc)alc_getattr,    /*tp_getattr*/
  665.     (setattrfunc)0,    /*tp_setattr*/
  666.     (cmpfunc)0,        /*tp_compare*/
  667.     (reprfunc)0,        /*tp_repr*/
  668.     0,            /*tp_as_number*/
  669.     0,        /*tp_as_sequence*/
  670.     0,        /*tp_as_mapping*/
  671.     (hashfunc)0,        /*tp_hash*/
  672.     (ternaryfunc)0,        /*tp_call*/
  673.     (reprfunc)0,        /*tp_str*/
  674.  
  675.     /* Space for future expansion */
  676.     0L,0L,0L,0L,
  677.     Alctype__doc__ /* Documentation string */
  678. };
  679.  
  680. /* End of code for config objects */
  681. /* ---------------------------------------------------------------- */
  682.  
  683. #ifdef AL_NO_ELEM        /* IRIX 6 */
  684.  
  685. static char alp_SetConfig__doc__[] = 
  686. "alSetConfig: set the ALconfig of an audio ALport."
  687. ;
  688.  
  689. static PyObject *
  690. alp_SetConfig(self, args)
  691.     alpobject *self;
  692.     PyObject *args;
  693. {
  694.     alcobject *config;
  695.     if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
  696.         return NULL;
  697.     if (alSetConfig(self->port, config->config) < 0)
  698.         return NULL;
  699.     Py_INCREF(Py_None);
  700.     return Py_None;
  701. }
  702.  
  703.  
  704. static char alp_GetConfig__doc__[] = 
  705. "alGetConfig: get the ALconfig of an audio ALport."
  706. ;
  707.  
  708. static PyObject *
  709. alp_GetConfig(self, args)
  710.     alpobject *self;
  711.     PyObject *args;
  712. {
  713.     ALconfig config;
  714.     if (!PyArg_ParseTuple(args, ":GetConfig"))
  715.         return NULL;
  716.     if ((config = alGetConfig(self->port)) == NULL)
  717.         return NULL;
  718.     return newalcobject(config);
  719. }
  720.  
  721.  
  722. static char alp_GetResource__doc__[] = 
  723. "alGetResource: get the resource associated with an audio port."
  724. ;
  725.  
  726. static PyObject *
  727. alp_GetResource(self, args)
  728.     alpobject *self;
  729.     PyObject *args;
  730. {
  731.     int resource;
  732.  
  733.     if (!PyArg_ParseTuple(args, ":GetResource"))
  734.         return NULL;
  735.     if ((resource = alGetResource(self->port)) == 0)
  736.         return NULL;
  737.     return PyInt_FromLong((long) resource);
  738. }
  739.  
  740.  
  741. static char alp_GetFD__doc__[] = 
  742. "alGetFD: get the file descriptor for an audio port."
  743. ;
  744.  
  745. static PyObject *
  746. alp_GetFD(self, args)
  747.     alpobject *self;
  748.     PyObject *args;
  749. {
  750.     int fd;
  751.  
  752.     if (!PyArg_ParseTuple(args, ":GetFD"))
  753.         return NULL;
  754.  
  755.     if ((fd = alGetFD(self->port)) < 0)
  756.         return NULL;
  757.  
  758.     return PyInt_FromLong((long) fd);
  759. }
  760.  
  761.  
  762. static char alp_GetFilled__doc__[] = 
  763. "alGetFilled: return the number of filled sample frames in an audio port."
  764. ;
  765.  
  766. static PyObject *
  767. alp_GetFilled(self, args)
  768.     alpobject *self;
  769.     PyObject *args;
  770. {
  771.     int filled;
  772.  
  773.     if (!PyArg_ParseTuple(args, ":GetFilled"))
  774.         return NULL;
  775.     if ((filled = alGetFilled(self->port)) < 0)
  776.         return NULL;
  777.     return PyInt_FromLong((long) filled);
  778. }
  779.  
  780.  
  781. static char alp_GetFillable__doc__[] = 
  782. "alGetFillable: report the number of unfilled sample frames in an audio port."
  783. ;
  784.  
  785. static PyObject *
  786. alp_GetFillable(self, args)
  787.     alpobject *self;
  788.     PyObject *args;
  789. {
  790.     int fillable;
  791.  
  792.     if (!PyArg_ParseTuple(args, ":GetFillable"))
  793.         return NULL;
  794.     if ((fillable = alGetFillable(self->port)) < 0)
  795.         return NULL;
  796.     return PyInt_FromLong((long) fillable);
  797. }
  798.  
  799.  
  800. static char alp_ReadFrames__doc__[] = 
  801. "alReadFrames: read sample frames from an audio port."
  802. ;
  803.  
  804. static PyObject *
  805. alp_ReadFrames(self, args)
  806.     alpobject *self;
  807.     PyObject *args;
  808. {
  809.     void *samples;
  810.     int framecount;
  811.     PyObject *v;
  812.     int size;
  813.     int ch;
  814.     ALconfig c;
  815.  
  816.     if (!PyArg_ParseTuple(args, "i:ReadFrames", &framecount))
  817.         return NULL;
  818.     if (framecount < 0) {
  819.         PyErr_SetString(ErrorObject, "negative framecount");
  820.         return NULL;
  821.     }
  822.     c = alGetConfig(self->port);
  823.     switch (alGetSampFmt(c)) {
  824.     case AL_SAMPFMT_TWOSCOMP:
  825.         switch (alGetWidth(c)) {
  826.         case AL_SAMPLE_8:
  827.             size = 1;
  828.             break;
  829.         case AL_SAMPLE_16:
  830.             size = 2;
  831.             break;
  832.         case AL_SAMPLE_24:
  833.             size = 4;
  834.             break;
  835.         default:
  836.             PyErr_SetString(ErrorObject, "can't determine width");
  837.             alFreeConfig(c);
  838.             return NULL;
  839.         }
  840.         break;
  841.     case AL_SAMPFMT_FLOAT:
  842.         size = 4;
  843.         break;
  844.     case AL_SAMPFMT_DOUBLE:
  845.         size = 8;
  846.         break;
  847.     default:
  848.         PyErr_SetString(ErrorObject, "can't determine format");
  849.         alFreeConfig(c);
  850.         return NULL;
  851.     }
  852.     ch = alGetChannels(c);
  853.     alFreeConfig(c);
  854.     if (ch < 0) {
  855.         PyErr_SetString(ErrorObject, "can't determine # of channels");
  856.         return NULL;
  857.     }
  858.     size *= ch;
  859.     v = PyString_FromStringAndSize((char *) NULL, size * framecount);
  860.     if (v == NULL)
  861.         return NULL;
  862.  
  863.     Py_BEGIN_ALLOW_THREADS
  864.     alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);
  865.     Py_END_ALLOW_THREADS
  866.  
  867.     return v;
  868. }
  869.  
  870.  
  871. static char alp_DiscardFrames__doc__[] = 
  872. "alDiscardFrames: discard audio from an audio port."
  873. ;
  874.  
  875. static PyObject *
  876. alp_DiscardFrames(self, args)
  877.     alpobject *self;
  878.     PyObject *args;
  879. {
  880.     int framecount;
  881.  
  882.     if (!PyArg_ParseTuple(args, "i:DiscardFrames", &framecount))
  883.         return NULL;
  884.  
  885.     Py_BEGIN_ALLOW_THREADS
  886.     framecount = alDiscardFrames(self->port, framecount);
  887.     Py_END_ALLOW_THREADS
  888.  
  889.     if (framecount < 0)
  890.         return NULL;
  891.  
  892.     return PyInt_FromLong((long) framecount);
  893. }
  894.  
  895.  
  896. static char alp_ZeroFrames__doc__[] = 
  897. "alZeroFrames: write zero-valued sample frames to an audio port."
  898. ;
  899.  
  900. static PyObject *
  901. alp_ZeroFrames(self, args)
  902.     alpobject *self;
  903.     PyObject *args;
  904. {
  905.     int framecount;
  906.  
  907.     if (!PyArg_ParseTuple(args, "i:ZeroFrames", &framecount))
  908.         return NULL;
  909.  
  910.     if (framecount < 0) {
  911.         PyErr_SetString(ErrorObject, "negative framecount");
  912.         return NULL;
  913.     }
  914.  
  915.     Py_BEGIN_ALLOW_THREADS
  916.     alZeroFrames(self->port, framecount);
  917.     Py_END_ALLOW_THREADS
  918.  
  919.     Py_INCREF(Py_None);
  920.     return Py_None;
  921. }
  922.  
  923.  
  924. static char alp_SetFillPoint__doc__[] = 
  925. "alSetFillPoint: set low- or high-water mark for an audio port."
  926. ;
  927.  
  928. static PyObject *
  929. alp_SetFillPoint(self, args)
  930.     alpobject *self;
  931.     PyObject *args;
  932. {
  933.     int fillpoint;
  934.  
  935.     if (!PyArg_ParseTuple(args, "i:SetFillPoint", &fillpoint))
  936.         return NULL;
  937.  
  938.     if (alSetFillPoint(self->port, fillpoint) < 0)
  939.         return NULL;
  940.  
  941.     Py_INCREF(Py_None);
  942.     return Py_None;
  943. }
  944.  
  945.  
  946. static char alp_GetFillPoint__doc__[] = 
  947. "alGetFillPoint: get low- or high-water mark for an audio port."
  948. ;
  949.  
  950. static PyObject *
  951. alp_GetFillPoint(self, args)
  952.     alpobject *self;
  953.     PyObject *args;
  954. {
  955.     int fillpoint;
  956.  
  957.     if (!PyArg_ParseTuple(args, ":GetFillPoint"))
  958.         return NULL;
  959.  
  960.     if ((fillpoint = alGetFillPoint(self->port)) < 0)
  961.         return NULL;
  962.  
  963.     return PyInt_FromLong((long) fillpoint);
  964. }
  965.  
  966.  
  967. static char alp_GetFrameNumber__doc__[] = 
  968. "alGetFrameNumber: get the absolute sample frame number associated with a port."
  969. ;
  970.  
  971. static PyObject *
  972. alp_GetFrameNumber(self, args)
  973.     alpobject *self;
  974.     PyObject *args;
  975. {
  976.     stamp_t fnum;
  977.  
  978.     if (!PyArg_ParseTuple(args, ":GetFrameNumber"))
  979.         return NULL;
  980.  
  981.     if (alGetFrameNumber(self->port, &fnum) < 0)
  982.         return NULL;
  983.  
  984.     return PyLong_FromLongLong((long long) fnum);
  985. }
  986.  
  987.  
  988. static char alp_GetFrameTime__doc__[] = 
  989. "alGetFrameTime: get the time at which a sample frame came in or will go out."
  990. ;
  991.  
  992. static PyObject *
  993. alp_GetFrameTime(self, args)
  994.     alpobject *self;
  995.     PyObject *args;
  996. {
  997.     stamp_t fnum, time;
  998.     PyObject *ret, *v0, *v1;
  999.  
  1000.     if (!PyArg_ParseTuple(args, ":GetFrameTime"))
  1001.         return NULL;
  1002.     if (alGetFrameTime(self->port, &fnum, &time) < 0)
  1003.         return NULL;
  1004.     v0 = PyLong_FromLongLong((long long) fnum);
  1005.     v1 = PyLong_FromLongLong((long long) time);
  1006.     if (PyErr_Occurred()) {
  1007.         Py_XDECREF(v0);
  1008.         Py_XDECREF(v1);
  1009.         return NULL;
  1010.     }
  1011.     ret = Py_BuildValue("(OO)", v0, v1);
  1012.     Py_DECREF(v0);
  1013.     Py_DECREF(v1);
  1014.     return ret;
  1015. }
  1016.  
  1017.  
  1018. static char alp_WriteFrames__doc__[] = 
  1019. "alWriteFrames: write sample frames to an audio port."
  1020. ;
  1021.  
  1022. static PyObject *
  1023. alp_WriteFrames(self, args)
  1024.     alpobject *self;
  1025.     PyObject *args;
  1026. {
  1027.     char *samples;
  1028.     int length;
  1029.     int size, ch;
  1030.     ALconfig c;
  1031.  
  1032.     if (!PyArg_ParseTuple(args, "s#:WriteFrames", &samples, &length))
  1033.         return NULL;
  1034.     c = alGetConfig(self->port);
  1035.     switch (alGetSampFmt(c)) {
  1036.     case AL_SAMPFMT_TWOSCOMP:
  1037.         switch (alGetWidth(c)) {
  1038.         case AL_SAMPLE_8:
  1039.             size = 1;
  1040.             break;
  1041.         case AL_SAMPLE_16:
  1042.             size = 2;
  1043.             break;
  1044.         case AL_SAMPLE_24:
  1045.             size = 4;
  1046.             break;
  1047.         default:
  1048.             PyErr_SetString(ErrorObject, "can't determine width");
  1049.             alFreeConfig(c);
  1050.             return NULL;
  1051.         }
  1052.         break;
  1053.     case AL_SAMPFMT_FLOAT:
  1054.         size = 4;
  1055.         break;
  1056.     case AL_SAMPFMT_DOUBLE:
  1057.         size = 8;
  1058.         break;
  1059.     default:
  1060.         PyErr_SetString(ErrorObject, "can't determine format");
  1061.         alFreeConfig(c);
  1062.         return NULL;
  1063.     }
  1064.     ch = alGetChannels(c);
  1065.     alFreeConfig(c);
  1066.     if (ch < 0) {
  1067.         PyErr_SetString(ErrorObject, "can't determine # of channels");
  1068.         return NULL;
  1069.     }
  1070.     size *= ch;
  1071.     if (length % size != 0) {
  1072.         PyErr_SetString(ErrorObject,
  1073.                 "buffer length not whole number of frames");
  1074.         return NULL;
  1075.     }
  1076.  
  1077.     Py_BEGIN_ALLOW_THREADS
  1078.     alWriteFrames(self->port, (void *) samples, length / size);
  1079.     Py_END_ALLOW_THREADS
  1080.  
  1081.     Py_INCREF(Py_None);
  1082.     return Py_None;
  1083. }
  1084.  
  1085.  
  1086. static char alp_ClosePort__doc__[] = 
  1087. "alClosePort: close an audio port."
  1088. ;
  1089.  
  1090. static PyObject *
  1091. alp_ClosePort(self, args)
  1092.     alpobject *self;
  1093.     PyObject *args;
  1094. {
  1095.     if (!PyArg_ParseTuple(args, ":ClosePort"))
  1096.         return NULL;
  1097.     if (alClosePort(self->port) < 0)
  1098.         return NULL;
  1099.     self->port = NULL;
  1100.     Py_INCREF(Py_None);
  1101.     return Py_None;
  1102. }
  1103.  
  1104. #endif /* AL_NO_ELEM */
  1105.  
  1106. #ifdef OLD_INTERFACE
  1107. static PyObject *
  1108. alp_closeport(self, args)
  1109.     alpobject *self;
  1110.     PyObject *args;
  1111. {
  1112.     if (!PyArg_ParseTuple(args, ":ClosePort"))
  1113.         return NULL;
  1114.     if (ALcloseport(self->port) < 0)
  1115.         return NULL;
  1116.     self->port = NULL;
  1117.     Py_INCREF(Py_None);
  1118.     return Py_None;
  1119. }
  1120.  
  1121. static PyObject *
  1122. alp_getfd(self, args)
  1123.     alpobject *self;
  1124.     PyObject *args;
  1125. {
  1126.     int fd;
  1127.  
  1128.     if (!PyArg_ParseTuple(args, ":GetFD"))
  1129.         return NULL;
  1130.     if ((fd = ALgetfd(self-> port)) == -1)
  1131.         return NULL;
  1132.     return PyInt_FromLong(fd);
  1133. }
  1134.  
  1135. static PyObject *
  1136. alp_getfilled(self, args)
  1137.     alpobject *self;
  1138.     PyObject *args;
  1139. {
  1140.     long count;
  1141.  
  1142.     if (!PyArg_ParseTuple(args, ":GetFilled"))
  1143.         return NULL;
  1144.     if ((count = ALgetfilled(self-> port)) == -1)
  1145.         return NULL;
  1146.     return PyInt_FromLong(count);
  1147. }
  1148.  
  1149. static PyObject *
  1150. alp_getfillable(self, args)
  1151.     alpobject *self;
  1152.     PyObject *args;
  1153. {
  1154.     long count;
  1155.  
  1156.     if (!PyArg_ParseTuple(args, ":GetFillable"))
  1157.         return NULL;
  1158.     if ((count = ALgetfillable(self-> port)) == -1)
  1159.         return NULL;
  1160.     return PyInt_FromLong (count);
  1161. }
  1162.  
  1163. static PyObject *
  1164. alp_readsamps(self, args)
  1165.     alpobject *self;
  1166.     PyObject *args;
  1167. {
  1168.     long count;
  1169.     PyObject *v;
  1170.     ALconfig c;
  1171.     int width;
  1172.     int ret;
  1173.  
  1174.     if (!PyArg_ParseTuple(args, "l:readsamps", &count))
  1175.         return NULL;
  1176.  
  1177.     if (count <= 0) {
  1178.         PyErr_SetString(ErrorObject, "al.readsamps : arg <= 0");
  1179.         return NULL;
  1180.     }
  1181.  
  1182.     c = ALgetconfig(self->port);
  1183. #ifdef AL_405
  1184.     width = ALgetsampfmt(c);
  1185.     if (width == AL_SAMPFMT_FLOAT)
  1186.         width = sizeof(float);
  1187.     else if (width == AL_SAMPFMT_DOUBLE)
  1188.         width = sizeof(double);
  1189.     else
  1190.         width = ALgetwidth(c);
  1191. #else
  1192.     width = ALgetwidth(c);
  1193. #endif /* AL_405 */
  1194.     ALfreeconfig(c);
  1195.     v = PyString_FromStringAndSize((char *)NULL, width * count);
  1196.     if (v == NULL)
  1197.         return NULL;
  1198.  
  1199.     Py_BEGIN_ALLOW_THREADS
  1200.     ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count);
  1201.     Py_END_ALLOW_THREADS
  1202.     if (ret == -1) {
  1203.         Py_DECREF(v);
  1204.         return NULL;
  1205.     }
  1206.  
  1207.     return (v);
  1208. }
  1209.  
  1210. static PyObject *
  1211. alp_writesamps(self, args)
  1212.     alpobject *self;
  1213.     PyObject *args;
  1214. {
  1215.     char *buf;
  1216.     int size, width;
  1217.     ALconfig c;
  1218.     int ret;
  1219.  
  1220.     if (!PyArg_ParseTuple(args, "s#:writesamps", &buf, &size))
  1221.         return NULL;
  1222.  
  1223.     c = ALgetconfig(self->port);
  1224. #ifdef AL_405
  1225.     width = ALgetsampfmt(c);
  1226.     if (width == AL_SAMPFMT_FLOAT)
  1227.         width = sizeof(float);
  1228.     else if (width == AL_SAMPFMT_DOUBLE)
  1229.         width = sizeof(double);
  1230.     else
  1231.         width = ALgetwidth(c);
  1232. #else
  1233.     width = ALgetwidth(c);
  1234. #endif /* AL_405 */
  1235.     ALfreeconfig(c);
  1236.     Py_BEGIN_ALLOW_THREADS
  1237.     ret = ALwritesamps (self->port, (void *) buf, (long) size / width);
  1238.     Py_END_ALLOW_THREADS
  1239.     if (ret == -1)
  1240.         return NULL;
  1241.  
  1242.     Py_INCREF(Py_None);
  1243.     return Py_None;
  1244. }
  1245.  
  1246. static PyObject *
  1247. alp_getfillpoint(self, args)
  1248.     alpobject *self;
  1249.     PyObject *args;
  1250. {
  1251.     long count;
  1252.  
  1253.     if (!PyArg_ParseTuple(args, ":GetFillPoint"))
  1254.         return NULL;
  1255.     if ((count = ALgetfillpoint(self->port)) == -1)
  1256.         return NULL;
  1257.     return PyInt_FromLong(count);
  1258. }
  1259.  
  1260. static PyObject *
  1261. alp_setfillpoint(self, args)
  1262.     alpobject *self;
  1263.     PyObject *args;
  1264. {
  1265.     long count;
  1266.  
  1267.     if (!PyArg_ParseTuple(args, "l:SetFillPoint", &count))
  1268.         return NULL;
  1269.     if (ALsetfillpoint(self->port, count) == -1)
  1270.         return NULL;
  1271.     Py_INCREF(Py_None);
  1272.     return Py_None;
  1273. }
  1274.  
  1275. static PyObject *
  1276. alp_setconfig(self, args)
  1277.     alpobject *self;
  1278.     PyObject *args;
  1279. {
  1280.     alcobject *config;
  1281.  
  1282.     if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))
  1283.         return NULL;
  1284.     if (ALsetconfig(self->port, config->config) == -1)
  1285.         return NULL;
  1286.     Py_INCREF(Py_None);
  1287.     return Py_None;
  1288. }
  1289.  
  1290. static PyObject *
  1291. alp_getconfig(self, args)
  1292.     alpobject *self;
  1293.     PyObject *args;
  1294. {
  1295.     ALconfig config;
  1296.  
  1297.     if (!PyArg_ParseTuple(args, ":GetConfig"))
  1298.         return NULL;
  1299.     config = ALgetconfig(self->port);
  1300.     if (config == NULL)
  1301.         return NULL;
  1302.     return newalcobject(config);
  1303. }
  1304.  
  1305. #ifdef AL_405
  1306. static PyObject *
  1307. alp_getstatus(self, args)
  1308.     alpobject *self;
  1309.     PyObject *args;
  1310. {
  1311.     PyObject *list, *v;
  1312.     long *PVbuffer;
  1313.     long length;
  1314.     int i;
  1315.     
  1316.     if (!PyArg_Parse(args, "O!", &PyList_Type, &list))
  1317.         return NULL;
  1318.     length = PyList_Size(list);
  1319.     PVbuffer = PyMem_NEW(long, length);
  1320.     if (PVbuffer == NULL)
  1321.         return PyErr_NoMemory();
  1322.     for (i = 0; i < length; i++) {
  1323.         v = PyList_GetItem(list, i);
  1324.         if (!PyInt_Check(v)) {
  1325.             PyMem_DEL(PVbuffer);
  1326.             PyErr_BadArgument();
  1327.             return NULL;
  1328.         }
  1329.         PVbuffer[i] = PyInt_AsLong(v);
  1330.     }
  1331.  
  1332.     if (ALgetstatus(self->port, PVbuffer, length) == -1)
  1333.         return NULL;
  1334.  
  1335.     for (i = 0; i < length; i++)
  1336.         PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
  1337.  
  1338.     PyMem_DEL(PVbuffer);
  1339.  
  1340.     Py_INCREF(Py_None);
  1341.     return Py_None;
  1342. }
  1343. #endif /* AL_405 */
  1344.  
  1345. #endif /* OLD_INTERFACE */
  1346.  
  1347. static struct PyMethodDef alp_methods[] = {
  1348. #ifdef AL_NO_ELEM        /* IRIX 6 */
  1349.     {"SetConfig",    (PyCFunction)alp_SetConfig,    METH_VARARGS,    alp_SetConfig__doc__},
  1350.     {"GetConfig",    (PyCFunction)alp_GetConfig,    METH_VARARGS,    alp_GetConfig__doc__},
  1351.     {"GetResource",    (PyCFunction)alp_GetResource,    METH_VARARGS,    alp_GetResource__doc__},
  1352.     {"GetFD",    (PyCFunction)alp_GetFD,    METH_VARARGS,    alp_GetFD__doc__},
  1353.     {"GetFilled",    (PyCFunction)alp_GetFilled,    METH_VARARGS,    alp_GetFilled__doc__},
  1354.     {"GetFillable",    (PyCFunction)alp_GetFillable,    METH_VARARGS,    alp_GetFillable__doc__},
  1355.     {"ReadFrames",    (PyCFunction)alp_ReadFrames,    METH_VARARGS,    alp_ReadFrames__doc__},
  1356.     {"DiscardFrames",    (PyCFunction)alp_DiscardFrames,    METH_VARARGS,    alp_DiscardFrames__doc__},
  1357.     {"ZeroFrames",    (PyCFunction)alp_ZeroFrames,    METH_VARARGS,    alp_ZeroFrames__doc__},
  1358.     {"SetFillPoint",    (PyCFunction)alp_SetFillPoint,    METH_VARARGS,    alp_SetFillPoint__doc__},
  1359.     {"GetFillPoint",    (PyCFunction)alp_GetFillPoint,    METH_VARARGS,    alp_GetFillPoint__doc__},
  1360.     {"GetFrameNumber",    (PyCFunction)alp_GetFrameNumber,    METH_VARARGS,    alp_GetFrameNumber__doc__},
  1361.     {"GetFrameTime",    (PyCFunction)alp_GetFrameTime,    METH_VARARGS,    alp_GetFrameTime__doc__},
  1362.     {"WriteFrames",    (PyCFunction)alp_WriteFrames,    METH_VARARGS,    alp_WriteFrames__doc__},
  1363.     {"ClosePort",    (PyCFunction)alp_ClosePort,    METH_VARARGS,    alp_ClosePort__doc__},
  1364. #endif /* AL_NO_ELEM */
  1365. #ifdef OLD_INTERFACE
  1366.     {"closeport",        (PyCFunction)alp_closeport,    METH_VARARGS},
  1367.     {"getfd",        (PyCFunction)alp_getfd,    METH_VARARGS},
  1368.         {"fileno",        (PyCFunction)alp_getfd,    METH_VARARGS},
  1369.     {"getfilled",        (PyCFunction)alp_getfilled,    METH_VARARGS},
  1370.     {"getfillable",        (PyCFunction)alp_getfillable,    METH_VARARGS},
  1371.     {"readsamps",        (PyCFunction)alp_readsamps,    METH_VARARGS},
  1372.     {"writesamps",        (PyCFunction)alp_writesamps,    METH_VARARGS},
  1373.     {"setfillpoint",    (PyCFunction)alp_setfillpoint,    METH_VARARGS},
  1374.     {"getfillpoint",    (PyCFunction)alp_getfillpoint,    METH_VARARGS},
  1375.     {"setconfig",        (PyCFunction)alp_setconfig,    METH_VARARGS},
  1376.     {"getconfig",        (PyCFunction)alp_getconfig,    METH_VARARGS},
  1377. #ifdef AL_405
  1378.     {"getstatus",        (PyCFunction)alp_getstatus,    METH_VARARGS},
  1379. #endif /* AL_405 */        
  1380. #endif /* OLD_INTERFACE */
  1381.  
  1382.     {NULL,        NULL}        /* sentinel */
  1383. };
  1384.  
  1385. /* ---------- */
  1386.  
  1387.  
  1388. static PyObject *
  1389. newalpobject(ALport port)
  1390. {
  1391.     alpobject *self;
  1392.     
  1393.     self = PyObject_New(alpobject, &Alptype);
  1394.     if (self == NULL)
  1395.         return NULL;
  1396.     /* XXXX Add your own initializers here */
  1397.     self->port = port;
  1398.     return (PyObject *) self;
  1399. }
  1400.  
  1401.  
  1402. static void
  1403. alp_dealloc(self)
  1404.     alpobject *self;
  1405. {
  1406.     /* XXXX Add your own cleanup code here */
  1407.     if (self->port) {
  1408. #ifdef AL_NO_ELEM        /* IRIX 6 */
  1409.         alClosePort(self->port);
  1410. #else
  1411.         ALcloseport(self->port);
  1412. #endif
  1413.     }
  1414.     PyObject_Del(self);
  1415. }
  1416.  
  1417. static PyObject *
  1418. alp_getattr(self, name)
  1419.     alpobject *self;
  1420.     char *name;
  1421. {
  1422.     /* XXXX Add your own getattr code here */
  1423.     if (self->port == NULL) {
  1424.         PyErr_SetString(ErrorObject, "port already closed");
  1425.         return NULL;
  1426.     }
  1427.     return Py_FindMethod(alp_methods, (PyObject *)self, name);
  1428. }
  1429.  
  1430. static char Alptype__doc__[] = 
  1431. ""
  1432. ;
  1433.  
  1434. static PyTypeObject Alptype = {
  1435.     PyObject_HEAD_INIT(&PyType_Type)
  1436.     0,                /*ob_size*/
  1437.     "port",            /*tp_name*/
  1438.     sizeof(alpobject),        /*tp_basicsize*/
  1439.     0,                /*tp_itemsize*/
  1440.     /* methods */
  1441.     (destructor)alp_dealloc,    /*tp_dealloc*/
  1442.     (printfunc)0,        /*tp_print*/
  1443.     (getattrfunc)alp_getattr,    /*tp_getattr*/
  1444.     (setattrfunc)0,    /*tp_setattr*/
  1445.     (cmpfunc)0,        /*tp_compare*/
  1446.     (reprfunc)0,        /*tp_repr*/
  1447.     0,            /*tp_as_number*/
  1448.     0,        /*tp_as_sequence*/
  1449.     0,        /*tp_as_mapping*/
  1450.     (hashfunc)0,        /*tp_hash*/
  1451.     (ternaryfunc)0,        /*tp_call*/
  1452.     (reprfunc)0,        /*tp_str*/
  1453.  
  1454.     /* Space for future expansion */
  1455.     0L,0L,0L,0L,
  1456.     Alptype__doc__ /* Documentation string */
  1457. };
  1458.  
  1459. /* End of code for port objects */
  1460. /* -------------------------------------------------------- */
  1461.  
  1462.  
  1463. #ifdef AL_NO_ELEM        /* IRIX 6 */
  1464.  
  1465. static char al_NewConfig__doc__[] =
  1466. "alNewConfig: create and initialize an audio ALconfig structure."
  1467. ;
  1468.  
  1469. static PyObject *
  1470. al_NewConfig(self, args)
  1471.     PyObject *self;    /* Not used */
  1472.     PyObject *args;
  1473. {
  1474.     ALconfig config;
  1475.  
  1476.     if (!PyArg_ParseTuple(args, ":NewConfig"))
  1477.         return NULL;
  1478.     if ((config = alNewConfig()) == NULL)
  1479.         return NULL;
  1480.     return newalcobject(config);
  1481. }
  1482.  
  1483. static char al_OpenPort__doc__[] =
  1484. "alOpenPort: open an audio port."
  1485. ;
  1486.  
  1487. static PyObject *
  1488. al_OpenPort(self, args)
  1489.     PyObject *self;    /* Not used */
  1490.     PyObject *args;
  1491. {
  1492.     ALport port;
  1493.     char *name, *dir;
  1494.     alcobject *config = NULL;
  1495.  
  1496.     if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
  1497.         return NULL;
  1498.     if ((port = alOpenPort(name, dir, config ? config->config : NULL)) == NULL)
  1499.         return NULL;
  1500.     return newalpobject(port);
  1501. }
  1502.  
  1503. static char al_Connect__doc__[] =
  1504. "alConnect: connect two audio I/O resources."
  1505. ;
  1506.  
  1507. static PyObject *
  1508. al_Connect(self, args)
  1509.     PyObject *self;    /* Not used */
  1510.     PyObject *args;
  1511. {
  1512.     int source, dest, nprops = 0, id, i;
  1513.     ALpv *props = NULL;
  1514.     ALparamInfo *propinfo = NULL;
  1515.     PyObject *propobj = NULL;
  1516.  
  1517.     if (!PyArg_ParseTuple(args, "ii|O!:Connect", &source, &dest, &PyList_Type, &propobj))
  1518.         return NULL;
  1519.     if (propobj != NULL) {
  1520.         nprops = python2params(source, dest, propobj, &props, &propinfo);
  1521.         if (nprops < 0)
  1522.             return NULL;
  1523.     }
  1524.  
  1525.     id = alConnect(source, dest, props, nprops);
  1526.  
  1527.     if (props) {
  1528.         for (i = 0; i < nprops; i++) {
  1529.             switch (propinfo[i].valueType) {
  1530.             case AL_SET_VAL:
  1531.             case AL_VECTOR_VAL:
  1532.                 PyMem_DEL(props[i].value.ptr);
  1533.                 break;
  1534.             }
  1535.         }
  1536.         PyMem_DEL(props);
  1537.         PyMem_DEL(propinfo);
  1538.     }
  1539.  
  1540.     if (id < 0)
  1541.         return NULL;
  1542.     return PyInt_FromLong((long) id);
  1543. }
  1544.  
  1545. static char al_Disconnect__doc__[] =
  1546. "alDisconnect: delete a connection between two audio I/O resources."
  1547. ;
  1548.  
  1549. static PyObject *
  1550. al_Disconnect(self, args)
  1551.     PyObject *self;    /* Not used */
  1552.     PyObject *args;
  1553. {
  1554.     int res;
  1555.  
  1556.     if (!PyArg_ParseTuple(args, "i:Disconnect", &res))
  1557.         return NULL;
  1558.     if (alDisconnect(res) < 0)
  1559.         return NULL;
  1560.     Py_INCREF(Py_None);
  1561.     return Py_None;
  1562. }
  1563.  
  1564. static char al_GetParams__doc__[] =
  1565. "alGetParams: get the values of audio resource parameters."
  1566. ;
  1567.  
  1568. static PyObject *
  1569. al_GetParams(self, args)
  1570.     PyObject *self;    /* Not used */
  1571.     PyObject *args;
  1572. {
  1573.     int resource;
  1574.     PyObject *pvslist, *item = NULL, *v = NULL;
  1575.     ALpv *pvs;
  1576.     int i, j, npvs;
  1577.     ALparamInfo *pinfo;
  1578.  
  1579.     if (!PyArg_ParseTuple(args, "iO!:GetParams", &resource, &PyList_Type, &pvslist))
  1580.         return NULL;
  1581.     npvs = PyList_Size(pvslist);
  1582.     pvs = PyMem_NEW(ALpv, npvs);
  1583.     pinfo = PyMem_NEW(ALparamInfo, npvs);
  1584.     for (i = 0; i < npvs; i++) {
  1585.         item = PyList_GetItem(pvslist, i);
  1586.         if (!PyInt_Check(item)) {
  1587.             item = NULL;
  1588.             PyErr_SetString(ErrorObject, "list of integers expected");
  1589.             goto error;
  1590.         }
  1591.         pvs[i].param = (int) PyInt_AsLong(item);
  1592.         item = NULL;    /* not needed anymore */
  1593.         if (alGetParamInfo(resource, pvs[i].param, &pinfo[i]) < 0)
  1594.             goto error;
  1595.         switch (pinfo[i].valueType) {
  1596.         case AL_NO_VAL:
  1597.             break;
  1598.         case AL_MATRIX_VAL:
  1599.             pinfo[i].maxElems *= pinfo[i].maxElems2;
  1600.             /* fall through */
  1601.         case AL_STRING_VAL:
  1602.         case AL_SET_VAL:
  1603.         case AL_VECTOR_VAL:
  1604.             switch (pinfo[i].elementType) {
  1605.             case AL_INT32_ELEM:
  1606.             case AL_RESOURCE_ELEM:
  1607.             case AL_ENUM_ELEM:
  1608.                 pvs[i].value.ptr = PyMem_NEW(int, pinfo[i].maxElems);
  1609.                 pvs[i].sizeIn = pinfo[i].maxElems;
  1610.                 break;
  1611.             case AL_INT64_ELEM:
  1612.             case AL_FIXED_ELEM:
  1613.                 pvs[i].value.ptr = PyMem_NEW(long long, pinfo[i].maxElems);
  1614.                 pvs[i].sizeIn = pinfo[i].maxElems;
  1615.                 break;
  1616.             case AL_CHAR_ELEM:
  1617.                 pvs[i].value.ptr = PyMem_NEW(char, 32);
  1618.                 pvs[i].sizeIn = 32;
  1619.                 break;
  1620.             case AL_NO_ELEM:
  1621.             case AL_PTR_ELEM:
  1622.             default:
  1623.                 PyErr_SetString(ErrorObject, "internal error");
  1624.                 goto error;
  1625.             }
  1626.             break;
  1627.         case AL_SCALAR_VAL:
  1628.             break;
  1629.         default:
  1630.             PyErr_SetString(ErrorObject, "internal error");
  1631.             goto error;
  1632.         }
  1633.         if (pinfo[i].valueType == AL_MATRIX_VAL) {
  1634.             pinfo[i].maxElems /= pinfo[i].maxElems2;
  1635.             pvs[i].sizeIn /= pinfo[i].maxElems2;
  1636.             pvs[i].size2In = pinfo[i].maxElems2;
  1637.         }
  1638.     }
  1639.     if (alGetParams(resource, pvs, npvs) < 0)
  1640.         goto error;
  1641.     v = PyList_New(npvs);
  1642.     for (i = 0; i < npvs; i++) {
  1643.         if (pvs[i].sizeOut < 0) {
  1644.             char buf[32];
  1645.             sprintf(buf, "problem with param %d", i);
  1646.             PyErr_SetString(ErrorObject, buf);
  1647.             goto error;
  1648.         }
  1649.         switch (pinfo[i].valueType) {
  1650.         case AL_NO_VAL:
  1651.             item = Py_None;
  1652.             Py_INCREF(item);
  1653.             break;
  1654.         case AL_STRING_VAL:
  1655.             item = PyString_FromString(pvs[i].value.ptr);
  1656.             PyMem_DEL(pvs[i].value.ptr);
  1657.             break;
  1658.         case AL_MATRIX_VAL:
  1659.             /* XXXX this is not right */
  1660.             pvs[i].sizeOut *= pvs[i].size2Out;
  1661.             /* fall through */
  1662.         case AL_SET_VAL:
  1663.         case AL_VECTOR_VAL:
  1664.             item = PyList_New(pvs[i].sizeOut);
  1665.             for (j = 0; j < pvs[i].sizeOut; j++) {
  1666.                 switch (pinfo[i].elementType) {
  1667.                 case AL_INT32_ELEM:
  1668.                 case AL_RESOURCE_ELEM:
  1669.                 case AL_ENUM_ELEM:
  1670.                     PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j]));
  1671.                     break;
  1672.                 case AL_INT64_ELEM:
  1673.                     PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j]));
  1674.                     break;
  1675.                 case AL_FIXED_ELEM:
  1676.                     PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j])));
  1677.                     break;
  1678.                 default:
  1679.                     PyErr_SetString(ErrorObject, "internal error");
  1680.                     goto error;
  1681.                 }
  1682.             }
  1683.             PyMem_DEL(pvs[i].value.ptr);
  1684.             break;
  1685.         case AL_SCALAR_VAL:
  1686.             item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]);
  1687.             break;
  1688.         }
  1689.         if (PyErr_Occurred() ||
  1690.             PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param,
  1691.                                item)) < 0 ||
  1692.             PyErr_Occurred())
  1693.             goto error;
  1694.         Py_DECREF(item);
  1695.     }
  1696.     PyMem_DEL(pvs);
  1697.     PyMem_DEL(pinfo);
  1698.     return v;
  1699.  
  1700.   error:
  1701.     Py_XDECREF(v);
  1702.     Py_XDECREF(item);
  1703.     if (pvs)
  1704.         PyMem_DEL(pvs);
  1705.     if (pinfo)
  1706.         PyMem_DEL(pinfo);
  1707.     return NULL;
  1708. }
  1709.  
  1710. static char al_SetParams__doc__[] =
  1711. "alSetParams: set the values of audio resource parameters."
  1712. ;
  1713.  
  1714. static PyObject *
  1715. al_SetParams(self, args)
  1716.     PyObject *self;    /* Not used */
  1717.     PyObject *args;
  1718. {
  1719.     int resource;
  1720.     PyObject *pvslist, *item;
  1721.     ALpv *pvs;
  1722.     ALparamInfo *pinfo;
  1723.     int npvs, i;
  1724.  
  1725.     if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist))
  1726.         return NULL;
  1727.     npvs = python2params(resource, -1, pvslist, &pvs, &pinfo);
  1728.     if (npvs < 0)
  1729.         return NULL;
  1730.  
  1731.     if (alSetParams(resource, pvs, npvs) < 0)
  1732.         goto error;
  1733.  
  1734.     /* cleanup */
  1735.     for (i = 0; i < npvs; i++) {
  1736.         switch (pinfo[i].valueType) {
  1737.         case AL_SET_VAL:
  1738.         case AL_VECTOR_VAL:
  1739.             PyMem_DEL(pvs[i].value.ptr);
  1740.             break;
  1741.         }
  1742.     }
  1743.     PyMem_DEL(pvs);
  1744.     PyMem_DEL(pinfo);
  1745.  
  1746.     Py_INCREF(Py_None);
  1747.     return Py_None;
  1748.  
  1749.   error:
  1750.     /* XXXX we should clean up everything */
  1751.     if (pvs)
  1752.         PyMem_DEL(pvs);
  1753.     if (pinfo)
  1754.         PyMem_DEL(pinfo);
  1755.     return NULL;
  1756. }
  1757.  
  1758. static char al_QueryValues__doc__[] =
  1759. "alQueryValues: get the set of possible values for a parameter."
  1760. ;
  1761.  
  1762. static PyObject *
  1763. al_QueryValues(self, args)
  1764.     PyObject *self;    /* Not used */
  1765.     PyObject *args;
  1766. {
  1767.     int resource, param;
  1768.     ALvalue *return_set = NULL;
  1769.     int setsize = 32, qualsize = 0, nvals, i;
  1770.     ALpv *quals = NULL;
  1771.     ALparamInfo pinfo;
  1772.     ALparamInfo *qualinfo = NULL;
  1773.     PyObject *qualobj = NULL;
  1774.     PyObject *res = NULL, *item;
  1775.  
  1776.     if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, ¶m,
  1777.                   &PyList_Type, &qualobj))
  1778.         return NULL;
  1779.     if (qualobj != NULL) {
  1780.         qualsize = python2params(resource, param, qualobj, &quals, &qualinfo);
  1781.         if (qualsize < 0)
  1782.             return NULL;
  1783.     }
  1784.     setsize = 32;
  1785.     return_set = PyMem_NEW(ALvalue, setsize);
  1786.     if (return_set == NULL) {
  1787.         PyErr_NoMemory();
  1788.         goto cleanup;
  1789.     }
  1790.  
  1791.   retry:
  1792.     nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize);
  1793.     if (nvals < 0)
  1794.         goto cleanup;
  1795.     if (nvals > setsize) {
  1796.         setsize = nvals;
  1797.         PyMem_RESIZE(return_set, ALvalue, setsize);
  1798.         if (return_set == NULL) {
  1799.             PyErr_NoMemory();
  1800.             goto cleanup;
  1801.         }
  1802.         goto retry;
  1803.     }
  1804.  
  1805.     if (alGetParamInfo(resource, param, &pinfo) < 0)
  1806.         goto cleanup;
  1807.  
  1808.     res = PyList_New(nvals);
  1809.     if (res == NULL)
  1810.         goto cleanup;
  1811.     for (i = 0; i < nvals; i++) {
  1812.         item = param2python(resource, param, return_set[i], &pinfo);
  1813.         if (item == NULL ||
  1814.             PyList_SetItem(res, i, item) < 0) {
  1815.             Py_DECREF(res);
  1816.             res = NULL;
  1817.             goto cleanup;
  1818.         }
  1819.     }
  1820.  
  1821.   cleanup:
  1822.     if (return_set)
  1823.         PyMem_DEL(return_set);
  1824.     if (quals) {
  1825.         for (i = 0; i < qualsize; i++) {
  1826.             switch (qualinfo[i].valueType) {
  1827.             case AL_SET_VAL:
  1828.             case AL_VECTOR_VAL:
  1829.                 PyMem_DEL(quals[i].value.ptr);
  1830.                 break;
  1831.             }
  1832.         }
  1833.         PyMem_DEL(quals);
  1834.         PyMem_DEL(qualinfo);
  1835.     }
  1836.  
  1837.     return res;
  1838. }
  1839.  
  1840. static char al_GetParamInfo__doc__[] =
  1841. "alGetParamInfo: get information about a parameter on a particular audio resource."
  1842. ;
  1843.  
  1844. static PyObject *
  1845. al_GetParamInfo(self, args)
  1846.     PyObject *self;    /* Not used */
  1847.     PyObject *args;
  1848. {
  1849.     int res, param;
  1850.     ALparamInfo pinfo;
  1851.     PyObject *v, *item;;
  1852.  
  1853.     if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m))
  1854.         return NULL;
  1855.     if (alGetParamInfo(res, param, &pinfo) < 0)
  1856.         return NULL;
  1857.     v = PyDict_New();
  1858.  
  1859.     item = PyInt_FromLong((long) pinfo.resource);
  1860.     PyDict_SetItemString(v, "resource", item);
  1861.     Py_DECREF(item);
  1862.  
  1863.     item = PyInt_FromLong((long) pinfo.param);
  1864.     PyDict_SetItemString(v, "param", item);
  1865.     Py_DECREF(item);
  1866.  
  1867.     item = PyInt_FromLong((long) pinfo.valueType);
  1868.     PyDict_SetItemString(v, "valueType", item);
  1869.     Py_DECREF(item);
  1870.  
  1871.     if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) {
  1872.         /* multiple values */
  1873.         item = PyInt_FromLong((long) pinfo.maxElems);
  1874.         PyDict_SetItemString(v, "maxElems", item);
  1875.         Py_DECREF(item);
  1876.  
  1877.         if (pinfo.valueType == AL_MATRIX_VAL) {
  1878.             /* 2 dimensional */
  1879.             item = PyInt_FromLong((long) pinfo.maxElems2);
  1880.             PyDict_SetItemString(v, "maxElems2", item);
  1881.             Py_DECREF(item);
  1882.         }
  1883.     }
  1884.  
  1885.     item = PyInt_FromLong((long) pinfo.elementType);
  1886.     PyDict_SetItemString(v, "elementType", item);
  1887.     Py_DECREF(item);
  1888.  
  1889.     item = PyString_FromString(pinfo.name);
  1890.     PyDict_SetItemString(v, "name", item);
  1891.     Py_DECREF(item);
  1892.  
  1893.     item = param2python(res, param, pinfo.initial, &pinfo);
  1894.     PyDict_SetItemString(v, "initial", item);
  1895.     Py_DECREF(item);
  1896.  
  1897.     if (pinfo.elementType != AL_ENUM_ELEM &&
  1898.         pinfo.elementType != AL_RESOURCE_ELEM &&
  1899.         pinfo.elementType != AL_CHAR_ELEM) {
  1900.         /* range param */
  1901.         item = param2python(res, param, pinfo.min, &pinfo);
  1902.         PyDict_SetItemString(v, "min", item);
  1903.         Py_DECREF(item);
  1904.  
  1905.         item = param2python(res, param, pinfo.max, &pinfo);
  1906.         PyDict_SetItemString(v, "max", item);
  1907.         Py_DECREF(item);
  1908.  
  1909.         item = param2python(res, param, pinfo.minDelta, &pinfo);
  1910.         PyDict_SetItemString(v, "minDelta", item);
  1911.         Py_DECREF(item);
  1912.  
  1913.         item = param2python(res, param, pinfo.maxDelta, &pinfo);
  1914.         PyDict_SetItemString(v, "maxDelta", item);
  1915.         Py_DECREF(item);
  1916.  
  1917.         item = PyInt_FromLong((long) pinfo.specialVals);
  1918.         PyDict_SetItemString(v, "specialVals", item);
  1919.         Py_DECREF(item);
  1920.     }
  1921.  
  1922.     return v;
  1923. }
  1924.  
  1925. static char al_GetResourceByName__doc__[] =
  1926. "alGetResourceByName: find an audio resource by name."
  1927. ;
  1928.  
  1929. static PyObject *
  1930. al_GetResourceByName(self, args)
  1931.     PyObject *self;    /* Not used */
  1932.     PyObject *args;
  1933. {
  1934.     int res, start_res, type;
  1935.     char *name;
  1936.  
  1937.     if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type))
  1938.         return NULL;
  1939.     if ((res = alGetResourceByName(start_res, name, type)) == 0)
  1940.         return NULL;
  1941.     return PyInt_FromLong((long) res);
  1942. }
  1943.  
  1944. static char al_IsSubtype__doc__[] =
  1945. "alIsSubtype: indicate if one resource type is a subtype of another."
  1946. ;
  1947.  
  1948. static PyObject *
  1949. al_IsSubtype(self, args)
  1950.     PyObject *self;    /* Not used */
  1951.     PyObject *args;
  1952. {
  1953.     int type, subtype;
  1954.  
  1955.     if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype))
  1956.         return NULL;
  1957.     return PyInt_FromLong((long) alIsSubtype(type, subtype));
  1958. }
  1959.  
  1960. static char al_SetErrorHandler__doc__[] =
  1961. ""
  1962. ;
  1963.  
  1964. static PyObject *
  1965. al_SetErrorHandler(self, args)
  1966.     PyObject *self;    /* Not used */
  1967.     PyObject *args;
  1968. {
  1969.  
  1970.     if (!PyArg_ParseTuple(args, ":SetErrorHandler"))
  1971.         return NULL;
  1972.     Py_INCREF(Py_None);
  1973.     return Py_None;
  1974. }
  1975.  
  1976. #endif /* AL_NO_ELEM */
  1977.  
  1978. #ifdef OLD_INTERFACE
  1979.  
  1980. static PyObject *
  1981. al_openport(self, args)
  1982.     PyObject *self, *args;
  1983. {
  1984.     char *name, *dir;
  1985.     ALport port;
  1986.     alcobject *config = NULL;
  1987.  
  1988.     if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config))
  1989.         return NULL;
  1990.     if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL)
  1991.         return NULL;
  1992.     return newalpobject(port);
  1993. }
  1994.  
  1995. static PyObject *
  1996. al_newconfig(self, args)
  1997.     PyObject *self, *args;
  1998. {
  1999.     ALconfig config;
  2000.  
  2001.     if (!PyArg_ParseTuple(args, ":NewConfig"))
  2002.         return NULL;
  2003.     if ((config = ALnewconfig ()) == NULL)
  2004.         return NULL;
  2005.     return newalcobject(config);
  2006. }
  2007.  
  2008. static PyObject *
  2009. al_queryparams(self, args)
  2010.     PyObject *self, *args;
  2011. {
  2012.     long device;
  2013.     long length;
  2014.     long *PVbuffer;
  2015.     long PVdummy[2];
  2016.     PyObject *v = NULL;
  2017.     int i;
  2018.  
  2019.     if (!PyArg_ParseTuple(args, "l:queryparams", &device))
  2020.         return NULL;
  2021.     if ((length = ALqueryparams(device, PVdummy, 2L)) == -1)
  2022.         return NULL;
  2023.     if ((PVbuffer = PyMem_NEW(long, length)) == NULL)
  2024.         return PyErr_NoMemory();
  2025.     if (ALqueryparams(device, PVbuffer, length) >= 0 &&
  2026.         (v = PyList_New((int)length)) != NULL) {
  2027.         for (i = 0; i < length; i++)
  2028.             PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i]));
  2029.     }
  2030.     PyMem_DEL(PVbuffer);
  2031.     return v;
  2032. }
  2033.  
  2034. static PyObject *
  2035. doParams(args, func, modified)
  2036.     PyObject *args;
  2037.     int (*func)(long, long *, long);
  2038.     int modified;
  2039. {
  2040.     long device;
  2041.     PyObject *list, *v;
  2042.     long *PVbuffer;
  2043.     long length;
  2044.     int i;
  2045.     
  2046.     if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list))
  2047.         return NULL;
  2048.     length = PyList_Size(list);
  2049.     PVbuffer = PyMem_NEW(long, length);
  2050.     if (PVbuffer == NULL)
  2051.         return PyErr_NoMemory();
  2052.     for (i = 0; i < length; i++) {
  2053.         v = PyList_GetItem(list, i);
  2054.         if (!PyInt_Check(v)) {
  2055.             PyMem_DEL(PVbuffer);
  2056.             PyErr_BadArgument();
  2057.             return NULL;
  2058.         }
  2059.         PVbuffer[i] = PyInt_AsLong(v);
  2060.     }
  2061.  
  2062.     if ((*func)(device, PVbuffer, length) == -1) {
  2063.         PyMem_DEL(PVbuffer);
  2064.         return NULL;
  2065.     }
  2066.  
  2067.     if (modified) {
  2068.         for (i = 0; i < length; i++)
  2069.             PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i]));
  2070.     }
  2071.  
  2072.     PyMem_DEL(PVbuffer);
  2073.  
  2074.     Py_INCREF(Py_None);
  2075.     return Py_None;
  2076. }
  2077.  
  2078. static PyObject *
  2079. al_getparams(self, args)
  2080.     PyObject *self, *args;
  2081. {
  2082.     return doParams(args, ALgetparams, 1);
  2083. }
  2084.  
  2085. static PyObject *
  2086. al_setparams(self, args)
  2087.     PyObject *self, *args;
  2088. {
  2089.     return doParams(args, ALsetparams, 0);
  2090. }
  2091.  
  2092. static PyObject *
  2093. al_getname(self, args)
  2094.     PyObject *self, *args;
  2095. {
  2096.     long device, descriptor;
  2097.     char *name;
  2098.  
  2099.     if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor))
  2100.         return NULL;
  2101.     if ((name = ALgetname(device, descriptor)) == NULL)
  2102.         return NULL;
  2103.     return PyString_FromString(name);
  2104. }
  2105.  
  2106. static PyObject *
  2107. al_getdefault(self, args)
  2108.     PyObject *self, *args;
  2109. {
  2110.     long device, descriptor, value;
  2111.  
  2112.     if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor))
  2113.         return NULL;
  2114.     if ((value = ALgetdefault(device, descriptor)) == -1)
  2115.         return NULL;
  2116.     return PyLong_FromLong(value);
  2117. }
  2118.  
  2119. static PyObject *
  2120. al_getminmax(self, args)
  2121.     PyObject *self, *args;
  2122. {
  2123.     long device, descriptor, min, max;
  2124.  
  2125.     if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor))
  2126.         return NULL;
  2127.     min = -1;
  2128.     max = -1;
  2129.     if (ALgetminmax(device, descriptor, &min, &max) == -1)
  2130.         return NULL;
  2131.     return Py_BuildValue("ll", min, max);
  2132. }
  2133.  
  2134. #endif /* OLD_INTERFACE */
  2135.  
  2136. /* List of methods defined in the module */
  2137.  
  2138. static struct PyMethodDef al_methods[] = {
  2139. #ifdef AL_NO_ELEM        /* IRIX 6 */
  2140.     {"NewConfig",    (PyCFunction)al_NewConfig,    METH_VARARGS,    al_NewConfig__doc__},
  2141.     {"OpenPort",    (PyCFunction)al_OpenPort,    METH_VARARGS,    al_OpenPort__doc__},
  2142.     {"Connect",    (PyCFunction)al_Connect,    METH_VARARGS,    al_Connect__doc__},
  2143.     {"Disconnect",    (PyCFunction)al_Disconnect,    METH_VARARGS,    al_Disconnect__doc__},
  2144.     {"GetParams",    (PyCFunction)al_GetParams,    METH_VARARGS,    al_GetParams__doc__},
  2145.     {"SetParams",    (PyCFunction)al_SetParams,    METH_VARARGS,    al_SetParams__doc__},
  2146.     {"QueryValues",    (PyCFunction)al_QueryValues,    METH_VARARGS,    al_QueryValues__doc__},
  2147.     {"GetParamInfo",    (PyCFunction)al_GetParamInfo,    METH_VARARGS,    al_GetParamInfo__doc__},
  2148.     {"GetResourceByName",    (PyCFunction)al_GetResourceByName,    METH_VARARGS,    al_GetResourceByName__doc__},
  2149.     {"IsSubtype",    (PyCFunction)al_IsSubtype,    METH_VARARGS,    al_IsSubtype__doc__},
  2150. #if 0
  2151.     /* this one not supported */
  2152.     {"SetErrorHandler",    (PyCFunction)al_SetErrorHandler,    METH_VARARGS,    al_SetErrorHandler__doc__},
  2153. #endif
  2154. #endif /* AL_NO_ELEM */
  2155. #ifdef OLD_INTERFACE
  2156.     {"openport",        (PyCFunction)al_openport,    METH_VARARGS},
  2157.     {"newconfig",        (PyCFunction)al_newconfig,    METH_VARARGS},
  2158.     {"queryparams",        (PyCFunction)al_queryparams,    METH_VARARGS},
  2159.     {"getparams",        (PyCFunction)al_getparams,    METH_VARARGS},
  2160.     {"setparams",        (PyCFunction)al_setparams,    METH_VARARGS},
  2161.     {"getname",        (PyCFunction)al_getname,    METH_VARARGS},
  2162.     {"getdefault",        (PyCFunction)al_getdefault,    METH_VARARGS},
  2163.     {"getminmax",        (PyCFunction)al_getminmax,    METH_VARARGS},
  2164. #endif /* OLD_INTERFACE */
  2165.  
  2166.     {NULL,     (PyCFunction)NULL, 0, NULL}        /* sentinel */
  2167. };
  2168.  
  2169.  
  2170. /* Initialization function for the module (*must* be called inital) */
  2171.  
  2172. static char al_module_documentation[] = 
  2173. ""
  2174. ;
  2175.  
  2176. void
  2177. inital()
  2178. {
  2179.     PyObject *m, *d, *x;
  2180.  
  2181.     /* Create the module and add the functions */
  2182.     m = Py_InitModule4("al", al_methods,
  2183.         al_module_documentation,
  2184.         (PyObject*)NULL,PYTHON_API_VERSION);
  2185.  
  2186.     /* Add some symbolic constants to the module */
  2187.     d = PyModule_GetDict(m);
  2188.     ErrorObject = PyString_FromString("al.error");
  2189.     PyDict_SetItemString(d, "error", ErrorObject);
  2190.  
  2191.     /* XXXX Add constants here */
  2192. #ifdef AL_4CHANNEL
  2193.     x =  PyInt_FromLong((long) AL_4CHANNEL);
  2194.     if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0)
  2195.         goto error;
  2196.     Py_DECREF(x);
  2197. #endif
  2198. #ifdef AL_ADAT_IF_TYPE
  2199.     x =  PyInt_FromLong((long) AL_ADAT_IF_TYPE);
  2200.     if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0)
  2201.         goto error;
  2202.     Py_DECREF(x);
  2203. #endif
  2204. #ifdef AL_ADAT_MCLK_TYPE
  2205.     x =  PyInt_FromLong((long) AL_ADAT_MCLK_TYPE);
  2206.     if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0)
  2207.         goto error;
  2208.     Py_DECREF(x);
  2209. #endif
  2210. #ifdef AL_AES_IF_TYPE
  2211.     x =  PyInt_FromLong((long) AL_AES_IF_TYPE);
  2212.     if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0)
  2213.         goto error;
  2214.     Py_DECREF(x);
  2215. #endif
  2216. #ifdef AL_AES_MCLK_TYPE
  2217.     x =  PyInt_FromLong((long) AL_AES_MCLK_TYPE);
  2218.     if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0)
  2219.         goto error;
  2220.     Py_DECREF(x);
  2221. #endif
  2222. #ifdef AL_ANALOG_IF_TYPE
  2223.     x =  PyInt_FromLong((long) AL_ANALOG_IF_TYPE);
  2224.     if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0)
  2225.         goto error;
  2226.     Py_DECREF(x);
  2227. #endif
  2228. #ifdef AL_ASSOCIATE
  2229.     x =  PyInt_FromLong((long) AL_ASSOCIATE);
  2230.     if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0)
  2231.         goto error;
  2232.     Py_DECREF(x);
  2233. #endif
  2234. #ifdef AL_BAD_BUFFER_NULL
  2235.     x =  PyInt_FromLong((long) AL_BAD_BUFFER_NULL);
  2236.     if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0)
  2237.         goto error;
  2238.     Py_DECREF(x);
  2239. #endif
  2240. #ifdef AL_BAD_BUFFERLENGTH
  2241.     x =  PyInt_FromLong((long) AL_BAD_BUFFERLENGTH);
  2242.     if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0)
  2243.         goto error;
  2244.     Py_DECREF(x);
  2245. #endif
  2246. #ifdef AL_BAD_BUFFERLENGTH_NEG
  2247.     x =  PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG);
  2248.     if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0)
  2249.         goto error;
  2250.     Py_DECREF(x);
  2251. #endif
  2252. #ifdef AL_BAD_BUFFERLENGTH_ODD
  2253.     x =  PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD);
  2254.     if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0)
  2255.         goto error;
  2256.     Py_DECREF(x);
  2257. #endif
  2258. #ifdef AL_BAD_CHANNELS
  2259.     x =  PyInt_FromLong((long) AL_BAD_CHANNELS);
  2260.     if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0)
  2261.         goto error;
  2262.     Py_DECREF(x);
  2263. #endif
  2264. #ifdef AL_BAD_CONFIG
  2265.     x =  PyInt_FromLong((long) AL_BAD_CONFIG);
  2266.     if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0)
  2267.         goto error;
  2268.     Py_DECREF(x);
  2269. #endif
  2270. #ifdef AL_BAD_COUNT_NEG
  2271.     x =  PyInt_FromLong((long) AL_BAD_COUNT_NEG);
  2272.     if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0)
  2273.         goto error;
  2274.     Py_DECREF(x);
  2275. #endif
  2276. #ifdef AL_BAD_DEVICE
  2277.     x =  PyInt_FromLong((long) AL_BAD_DEVICE);
  2278.     if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0)
  2279.         goto error;
  2280.     Py_DECREF(x);
  2281. #endif
  2282. #ifdef AL_BAD_DEVICE_ACCESS
  2283.     x =  PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS);
  2284.     if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0)
  2285.         goto error;
  2286.     Py_DECREF(x);
  2287. #endif
  2288. #ifdef AL_BAD_DIRECTION
  2289.     x =  PyInt_FromLong((long) AL_BAD_DIRECTION);
  2290.     if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0)
  2291.         goto error;
  2292.     Py_DECREF(x);
  2293. #endif
  2294. #ifdef AL_BAD_FILLPOINT
  2295.     x =  PyInt_FromLong((long) AL_BAD_FILLPOINT);
  2296.     if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0)
  2297.         goto error;
  2298.     Py_DECREF(x);
  2299. #endif
  2300. #ifdef AL_BAD_FLOATMAX
  2301.     x =  PyInt_FromLong((long) AL_BAD_FLOATMAX);
  2302.     if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0)
  2303.         goto error;
  2304.     Py_DECREF(x);
  2305. #endif
  2306. #ifdef AL_BAD_ILLEGAL_STATE
  2307.     x =  PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE);
  2308.     if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0)
  2309.         goto error;
  2310.     Py_DECREF(x);
  2311. #endif
  2312. #ifdef AL_BAD_NO_PORTS
  2313.     x =  PyInt_FromLong((long) AL_BAD_NO_PORTS);
  2314.     if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0)
  2315.         goto error;
  2316.     Py_DECREF(x);
  2317. #endif
  2318. #ifdef AL_BAD_NOT_FOUND
  2319.     x =  PyInt_FromLong((long) AL_BAD_NOT_FOUND);
  2320.     if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0)
  2321.         goto error;
  2322.     Py_DECREF(x);
  2323. #endif
  2324. #ifdef AL_BAD_NOT_IMPLEMENTED
  2325.     x =  PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED);
  2326.     if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0)
  2327.         goto error;
  2328.     Py_DECREF(x);
  2329. #endif
  2330. #ifdef AL_BAD_OUT_OF_MEM
  2331.     x =  PyInt_FromLong((long) AL_BAD_OUT_OF_MEM);
  2332.     if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0)
  2333.         goto error;
  2334.     Py_DECREF(x);
  2335. #endif
  2336. #ifdef AL_BAD_PARAM
  2337.     x =  PyInt_FromLong((long) AL_BAD_PARAM);
  2338.     if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0)
  2339.         goto error;
  2340.     Py_DECREF(x);
  2341. #endif
  2342. #ifdef AL_BAD_PERMISSIONS
  2343.     x =  PyInt_FromLong((long) AL_BAD_PERMISSIONS);
  2344.     if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0)
  2345.         goto error;
  2346.     Py_DECREF(x);
  2347. #endif
  2348. #ifdef AL_BAD_PORT
  2349.     x =  PyInt_FromLong((long) AL_BAD_PORT);
  2350.     if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0)
  2351.         goto error;
  2352.     Py_DECREF(x);
  2353. #endif
  2354. #ifdef AL_BAD_PORTSTYLE
  2355.     x =  PyInt_FromLong((long) AL_BAD_PORTSTYLE);
  2356.     if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0)
  2357.         goto error;
  2358.     Py_DECREF(x);
  2359. #endif
  2360. #ifdef AL_BAD_PVBUFFER
  2361.     x =  PyInt_FromLong((long) AL_BAD_PVBUFFER);
  2362.     if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0)
  2363.         goto error;
  2364.     Py_DECREF(x);
  2365. #endif
  2366. #ifdef AL_BAD_QSIZE
  2367.     x =  PyInt_FromLong((long) AL_BAD_QSIZE);
  2368.     if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0)
  2369.         goto error;
  2370.     Py_DECREF(x);
  2371. #endif
  2372. #ifdef AL_BAD_RATE
  2373.     x =  PyInt_FromLong((long) AL_BAD_RATE);
  2374.     if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0)
  2375.         goto error;
  2376.     Py_DECREF(x);
  2377. #endif
  2378. #ifdef AL_BAD_RESOURCE
  2379.     x =  PyInt_FromLong((long) AL_BAD_RESOURCE);
  2380.     if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0)
  2381.         goto error;
  2382.     Py_DECREF(x);
  2383. #endif
  2384. #ifdef AL_BAD_SAMPFMT
  2385.     x =  PyInt_FromLong((long) AL_BAD_SAMPFMT);
  2386.     if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0)
  2387.         goto error;
  2388.     Py_DECREF(x);
  2389. #endif
  2390. #ifdef AL_BAD_TRANSFER_SIZE
  2391.     x =  PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE);
  2392.     if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0)
  2393.         goto error;
  2394.     Py_DECREF(x);
  2395. #endif
  2396. #ifdef AL_BAD_WIDTH
  2397.     x =  PyInt_FromLong((long) AL_BAD_WIDTH);
  2398.     if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0)
  2399.         goto error;
  2400.     Py_DECREF(x);
  2401. #endif
  2402. #ifdef AL_CHANNEL_MODE
  2403.     x =  PyInt_FromLong((long) AL_CHANNEL_MODE);
  2404.     if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0)
  2405.         goto error;
  2406.     Py_DECREF(x);
  2407. #endif
  2408. #ifdef AL_CHANNELS
  2409.     x =  PyInt_FromLong((long) AL_CHANNELS);
  2410.     if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0)
  2411.         goto error;
  2412.     Py_DECREF(x);
  2413. #endif
  2414. #ifdef AL_CHAR_ELEM
  2415.     x =  PyInt_FromLong((long) AL_CHAR_ELEM);
  2416.     if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0)
  2417.         goto error;
  2418.     Py_DECREF(x);
  2419. #endif
  2420. #ifdef AL_CLOCK_GEN
  2421.     x =  PyInt_FromLong((long) AL_CLOCK_GEN);
  2422.     if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0)
  2423.         goto error;
  2424.     Py_DECREF(x);
  2425. #endif
  2426. #ifdef AL_CLOCKGEN_TYPE
  2427.     x =  PyInt_FromLong((long) AL_CLOCKGEN_TYPE);
  2428.     if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0)
  2429.         goto error;
  2430.     Py_DECREF(x);
  2431. #endif
  2432. #ifdef AL_CONNECT
  2433.     x =  PyInt_FromLong((long) AL_CONNECT);
  2434.     if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0)
  2435.         goto error;
  2436.     Py_DECREF(x);
  2437. #endif
  2438. #ifdef AL_CONNECTION_TYPE
  2439.     x =  PyInt_FromLong((long) AL_CONNECTION_TYPE);
  2440.     if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0)
  2441.         goto error;
  2442.     Py_DECREF(x);
  2443. #endif
  2444. #ifdef AL_CONNECTIONS
  2445.     x =  PyInt_FromLong((long) AL_CONNECTIONS);
  2446.     if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0)
  2447.         goto error;
  2448.     Py_DECREF(x);
  2449. #endif
  2450. #ifdef AL_CRYSTAL_MCLK_TYPE
  2451.     x =  PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE);
  2452.     if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0)
  2453.         goto error;
  2454.     Py_DECREF(x);
  2455. #endif
  2456. #ifdef AL_DEFAULT_DEVICE
  2457.     x =  PyInt_FromLong((long) AL_DEFAULT_DEVICE);
  2458.     if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0)
  2459.         goto error;
  2460.     Py_DECREF(x);
  2461. #endif
  2462. #ifdef AL_DEFAULT_INPUT
  2463.     x =  PyInt_FromLong((long) AL_DEFAULT_INPUT);
  2464.     if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0)
  2465.         goto error;
  2466.     Py_DECREF(x);
  2467. #endif
  2468. #ifdef AL_DEFAULT_OUTPUT
  2469.     x =  PyInt_FromLong((long) AL_DEFAULT_OUTPUT);
  2470.     if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0)
  2471.         goto error;
  2472.     Py_DECREF(x);
  2473. #endif
  2474. #ifdef AL_DEST
  2475.     x =  PyInt_FromLong((long) AL_DEST);
  2476.     if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0)
  2477.         goto error;
  2478.     Py_DECREF(x);
  2479. #endif
  2480. #ifdef AL_DEVICE_TYPE
  2481.     x =  PyInt_FromLong((long) AL_DEVICE_TYPE);
  2482.     if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0)
  2483.         goto error;
  2484.     Py_DECREF(x);
  2485. #endif
  2486. #ifdef AL_DEVICES
  2487.     x =  PyInt_FromLong((long) AL_DEVICES);
  2488.     if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0)
  2489.         goto error;
  2490.     Py_DECREF(x);
  2491. #endif
  2492. #ifdef AL_DIGITAL_IF_TYPE
  2493.     x =  PyInt_FromLong((long) AL_DIGITAL_IF_TYPE);
  2494.     if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0)
  2495.         goto error;
  2496.     Py_DECREF(x);
  2497. #endif
  2498. #ifdef AL_DIGITAL_INPUT_RATE
  2499.     x =  PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE);
  2500.     if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0)
  2501.         goto error;
  2502.     Py_DECREF(x);
  2503. #endif
  2504. #ifdef AL_DISCONNECT
  2505.     x =  PyInt_FromLong((long) AL_DISCONNECT);
  2506.     if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0)
  2507.         goto error;
  2508.     Py_DECREF(x);
  2509. #endif
  2510. #ifdef AL_ENUM_ELEM
  2511.     x =  PyInt_FromLong((long) AL_ENUM_ELEM);
  2512.     if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0)
  2513.         goto error;
  2514.     Py_DECREF(x);
  2515. #endif
  2516. #ifdef AL_ENUM_VALUE
  2517.     x =  PyInt_FromLong((long) AL_ENUM_VALUE);
  2518.     if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0)
  2519.         goto error;
  2520.     Py_DECREF(x);
  2521. #endif
  2522. #ifdef AL_ERROR_INPUT_OVERFLOW
  2523.     x =  PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW);
  2524.     if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0)
  2525.         goto error;
  2526.     Py_DECREF(x);
  2527. #endif
  2528. #ifdef AL_ERROR_LENGTH
  2529.     x =  PyInt_FromLong((long) AL_ERROR_LENGTH);
  2530.     if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0)
  2531.         goto error;
  2532.     Py_DECREF(x);
  2533. #endif
  2534. #ifdef AL_ERROR_LOCATION_LSP
  2535.     x =  PyInt_FromLong((long) AL_ERROR_LOCATION_LSP);
  2536.     if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0)
  2537.         goto error;
  2538.     Py_DECREF(x);
  2539. #endif
  2540. #ifdef AL_ERROR_LOCATION_MSP
  2541.     x =  PyInt_FromLong((long) AL_ERROR_LOCATION_MSP);
  2542.     if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0)
  2543.         goto error;
  2544.     Py_DECREF(x);
  2545. #endif
  2546. #ifdef AL_ERROR_NUMBER
  2547.     x =  PyInt_FromLong((long) AL_ERROR_NUMBER);
  2548.     if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0)
  2549.         goto error;
  2550.     Py_DECREF(x);
  2551. #endif
  2552. #ifdef AL_ERROR_OUTPUT_UNDERFLOW
  2553.     x =  PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW);
  2554.     if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0)
  2555.         goto error;
  2556.     Py_DECREF(x);
  2557. #endif
  2558. #ifdef AL_ERROR_TYPE
  2559.     x =  PyInt_FromLong((long) AL_ERROR_TYPE);
  2560.     if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0)
  2561.         goto error;
  2562.     Py_DECREF(x);
  2563. #endif
  2564. #ifdef AL_FIXED_ELEM
  2565.     x =  PyInt_FromLong((long) AL_FIXED_ELEM);
  2566.     if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0)
  2567.         goto error;
  2568.     Py_DECREF(x);
  2569. #endif
  2570. #ifdef AL_FIXED_MCLK_TYPE
  2571.     x =  PyInt_FromLong((long) AL_FIXED_MCLK_TYPE);
  2572.     if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0)
  2573.         goto error;
  2574.     Py_DECREF(x);
  2575. #endif
  2576. #ifdef AL_GAIN
  2577.     x =  PyInt_FromLong((long) AL_GAIN);
  2578.     if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0)
  2579.         goto error;
  2580.     Py_DECREF(x);
  2581. #endif
  2582. #ifdef AL_GAIN_REF
  2583.     x =  PyInt_FromLong((long) AL_GAIN_REF);
  2584.     if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0)
  2585.         goto error;
  2586.     Py_DECREF(x);
  2587. #endif
  2588. #ifdef AL_HRB_TYPE
  2589.     x =  PyInt_FromLong((long) AL_HRB_TYPE);
  2590.     if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0)
  2591.         goto error;
  2592.     Py_DECREF(x);
  2593. #endif
  2594. #ifdef AL_INPUT_COUNT
  2595.     x =  PyInt_FromLong((long) AL_INPUT_COUNT);
  2596.     if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0)
  2597.         goto error;
  2598.     Py_DECREF(x);
  2599. #endif
  2600. #ifdef AL_INPUT_DEVICE_TYPE
  2601.     x =  PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE);
  2602.     if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0)
  2603.         goto error;
  2604.     Py_DECREF(x);
  2605. #endif
  2606. #ifdef AL_INPUT_DIGITAL
  2607.     x =  PyInt_FromLong((long) AL_INPUT_DIGITAL);
  2608.     if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0)
  2609.         goto error;
  2610.     Py_DECREF(x);
  2611. #endif
  2612. #ifdef AL_INPUT_HRB_TYPE
  2613.     x =  PyInt_FromLong((long) AL_INPUT_HRB_TYPE);
  2614.     if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0)
  2615.         goto error;
  2616.     Py_DECREF(x);
  2617. #endif
  2618. #ifdef AL_INPUT_LINE
  2619.     x =  PyInt_FromLong((long) AL_INPUT_LINE);
  2620.     if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0)
  2621.         goto error;
  2622.     Py_DECREF(x);
  2623. #endif
  2624. #ifdef AL_INPUT_MIC
  2625.     x =  PyInt_FromLong((long) AL_INPUT_MIC);
  2626.     if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0)
  2627.         goto error;
  2628.     Py_DECREF(x);
  2629. #endif
  2630. #ifdef AL_INPUT_PORT_TYPE
  2631.     x =  PyInt_FromLong((long) AL_INPUT_PORT_TYPE);
  2632.     if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0)
  2633.         goto error;
  2634.     Py_DECREF(x);
  2635. #endif
  2636. #ifdef AL_INPUT_RATE
  2637.     x =  PyInt_FromLong((long) AL_INPUT_RATE);
  2638.     if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0)
  2639.         goto error;
  2640.     Py_DECREF(x);
  2641. #endif
  2642. #ifdef AL_INPUT_SOURCE
  2643.     x =  PyInt_FromLong((long) AL_INPUT_SOURCE);
  2644.     if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0)
  2645.         goto error;
  2646.     Py_DECREF(x);
  2647. #endif
  2648. #ifdef AL_INT32_ELEM
  2649.     x =  PyInt_FromLong((long) AL_INT32_ELEM);
  2650.     if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0)
  2651.         goto error;
  2652.     Py_DECREF(x);
  2653. #endif
  2654. #ifdef AL_INT64_ELEM
  2655.     x =  PyInt_FromLong((long) AL_INT64_ELEM);
  2656.     if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0)
  2657.         goto error;
  2658.     Py_DECREF(x);
  2659. #endif
  2660. #ifdef AL_INTERFACE
  2661.     x =  PyInt_FromLong((long) AL_INTERFACE);
  2662.     if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0)
  2663.         goto error;
  2664.     Py_DECREF(x);
  2665. #endif
  2666. #ifdef AL_INTERFACE_TYPE
  2667.     x =  PyInt_FromLong((long) AL_INTERFACE_TYPE);
  2668.     if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0)
  2669.         goto error;
  2670.     Py_DECREF(x);
  2671. #endif
  2672. #ifdef AL_INVALID_PARAM
  2673.     x =  PyInt_FromLong((long) AL_INVALID_PARAM);
  2674.     if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0)
  2675.         goto error;
  2676.     Py_DECREF(x);
  2677. #endif
  2678. #ifdef AL_INVALID_VALUE
  2679.     x =  PyInt_FromLong((long) AL_INVALID_VALUE);
  2680.     if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0)
  2681.         goto error;
  2682.     Py_DECREF(x);
  2683. #endif
  2684. #ifdef AL_JITTER
  2685.     x =  PyInt_FromLong((long) AL_JITTER);
  2686.     if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0)
  2687.         goto error;
  2688.     Py_DECREF(x);
  2689. #endif
  2690. #ifdef AL_LABEL
  2691.     x =  PyInt_FromLong((long) AL_LABEL);
  2692.     if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0)
  2693.         goto error;
  2694.     Py_DECREF(x);
  2695. #endif
  2696. #ifdef AL_LEFT_INPUT_ATTEN
  2697.     x =  PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN);
  2698.     if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0)
  2699.         goto error;
  2700.     Py_DECREF(x);
  2701. #endif
  2702. #ifdef AL_LEFT_MONITOR_ATTEN
  2703.     x =  PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN);
  2704.     if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0)
  2705.         goto error;
  2706.     Py_DECREF(x);
  2707. #endif
  2708. #ifdef AL_LEFT_SPEAKER_GAIN
  2709.     x =  PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN);
  2710.     if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0)
  2711.         goto error;
  2712.     Py_DECREF(x);
  2713. #endif
  2714. #ifdef AL_LEFT1_INPUT_ATTEN
  2715.     x =  PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN);
  2716.     if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0)
  2717.         goto error;
  2718.     Py_DECREF(x);
  2719. #endif
  2720. #ifdef AL_LEFT2_INPUT_ATTEN
  2721.     x =  PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN);
  2722.     if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0)
  2723.         goto error;
  2724.     Py_DECREF(x);
  2725. #endif
  2726. #ifdef AL_LINE_IF_TYPE
  2727.     x =  PyInt_FromLong((long) AL_LINE_IF_TYPE);
  2728.     if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0)
  2729.         goto error;
  2730.     Py_DECREF(x);
  2731. #endif
  2732. #ifdef AL_MASTER_CLOCK
  2733.     x =  PyInt_FromLong((long) AL_MASTER_CLOCK);
  2734.     if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0)
  2735.         goto error;
  2736.     Py_DECREF(x);
  2737. #endif
  2738. #ifdef AL_MATRIX_VAL
  2739.     x =  PyInt_FromLong((long) AL_MATRIX_VAL);
  2740.     if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0)
  2741.         goto error;
  2742.     Py_DECREF(x);
  2743. #endif
  2744. #ifdef AL_MAX_ERROR
  2745.     x =  PyInt_FromLong((long) AL_MAX_ERROR);
  2746.     if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0)
  2747.         goto error;
  2748.     Py_DECREF(x);
  2749. #endif
  2750. #ifdef AL_MAX_EVENT_PARAM
  2751.     x =  PyInt_FromLong((long) AL_MAX_EVENT_PARAM);
  2752.     if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0)
  2753.         goto error;
  2754.     Py_DECREF(x);
  2755. #endif
  2756. #ifdef AL_MAX_PBUFSIZE
  2757.     x =  PyInt_FromLong((long) AL_MAX_PBUFSIZE);
  2758.     if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0)
  2759.         goto error;
  2760.     Py_DECREF(x);
  2761. #endif
  2762. #ifdef AL_MAX_PORTS
  2763.     x =  PyInt_FromLong((long) AL_MAX_PORTS);
  2764.     if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0)
  2765.         goto error;
  2766.     Py_DECREF(x);
  2767. #endif
  2768. #ifdef AL_MAX_RESOURCE_ID
  2769.     x =  PyInt_FromLong((long) AL_MAX_RESOURCE_ID);
  2770.     if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0)
  2771.         goto error;
  2772.     Py_DECREF(x);
  2773. #endif
  2774. #ifdef AL_MAX_SETSIZE
  2775.     x =  PyInt_FromLong((long) AL_MAX_SETSIZE);
  2776.     if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0)
  2777.         goto error;
  2778.     Py_DECREF(x);
  2779. #endif
  2780. #ifdef AL_MAX_STRLEN
  2781.     x =  PyInt_FromLong((long) AL_MAX_STRLEN);
  2782.     if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0)
  2783.         goto error;
  2784.     Py_DECREF(x);
  2785. #endif
  2786. #ifdef AL_MCLK_TYPE
  2787.     x =  PyInt_FromLong((long) AL_MCLK_TYPE);
  2788.     if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0)
  2789.         goto error;
  2790.     Py_DECREF(x);
  2791. #endif
  2792. #ifdef AL_MIC_IF_TYPE
  2793.     x =  PyInt_FromLong((long) AL_MIC_IF_TYPE);
  2794.     if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0)
  2795.         goto error;
  2796.     Py_DECREF(x);
  2797. #endif
  2798. #ifdef AL_MONITOR_CTL
  2799.     x =  PyInt_FromLong((long) AL_MONITOR_CTL);
  2800.     if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0)
  2801.         goto error;
  2802.     Py_DECREF(x);
  2803. #endif
  2804. #ifdef AL_MONITOR_OFF
  2805.     x =  PyInt_FromLong((long) AL_MONITOR_OFF);
  2806.     if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0)
  2807.         goto error;
  2808.     Py_DECREF(x);
  2809. #endif
  2810. #ifdef AL_MONITOR_ON
  2811.     x =  PyInt_FromLong((long) AL_MONITOR_ON);
  2812.     if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0)
  2813.         goto error;
  2814.     Py_DECREF(x);
  2815. #endif
  2816. #ifdef AL_MONO
  2817.     x =  PyInt_FromLong((long) AL_MONO);
  2818.     if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0)
  2819.         goto error;
  2820.     Py_DECREF(x);
  2821. #endif
  2822. #ifdef AL_MUTE
  2823.     x =  PyInt_FromLong((long) AL_MUTE);
  2824.     if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0)
  2825.         goto error;
  2826.     Py_DECREF(x);
  2827. #endif
  2828. #ifdef AL_NAME
  2829.     x =  PyInt_FromLong((long) AL_NAME);
  2830.     if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0)
  2831.         goto error;
  2832.     Py_DECREF(x);
  2833. #endif
  2834. #ifdef AL_NEG_INFINITY
  2835.     x =  PyInt_FromLong((long) AL_NEG_INFINITY);
  2836.     if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0)
  2837.         goto error;
  2838.     Py_DECREF(x);
  2839. #endif
  2840. #ifdef AL_NEG_INFINITY_BIT
  2841.     x =  PyInt_FromLong((long) AL_NEG_INFINITY_BIT);
  2842.     if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0)
  2843.         goto error;
  2844.     Py_DECREF(x);
  2845. #endif
  2846. #ifdef AL_NO_CHANGE
  2847.     x =  PyInt_FromLong((long) AL_NO_CHANGE);
  2848.     if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0)
  2849.         goto error;
  2850.     Py_DECREF(x);
  2851. #endif
  2852. #ifdef AL_NO_CHANGE_BIT
  2853.     x =  PyInt_FromLong((long) AL_NO_CHANGE_BIT);
  2854.     if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0)
  2855.         goto error;
  2856.     Py_DECREF(x);
  2857. #endif
  2858. #ifdef AL_NO_ELEM
  2859.     x =  PyInt_FromLong((long) AL_NO_ELEM);
  2860.     if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0)
  2861.         goto error;
  2862.     Py_DECREF(x);
  2863. #endif
  2864. #ifdef AL_NO_ERRORS
  2865.     x =  PyInt_FromLong((long) AL_NO_ERRORS);
  2866.     if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0)
  2867.         goto error;
  2868.     Py_DECREF(x);
  2869. #endif
  2870. #ifdef AL_NO_OP
  2871.     x =  PyInt_FromLong((long) AL_NO_OP);
  2872.     if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0)
  2873.         goto error;
  2874.     Py_DECREF(x);
  2875. #endif
  2876. #ifdef AL_NO_VAL
  2877.     x =  PyInt_FromLong((long) AL_NO_VAL);
  2878.     if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0)
  2879.         goto error;
  2880.     Py_DECREF(x);
  2881. #endif
  2882. #ifdef AL_NULL_RESOURCE
  2883.     x =  PyInt_FromLong((long) AL_NULL_RESOURCE);
  2884.     if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0)
  2885.         goto error;
  2886.     Py_DECREF(x);
  2887. #endif
  2888. #ifdef AL_OUTPUT_COUNT
  2889.     x =  PyInt_FromLong((long) AL_OUTPUT_COUNT);
  2890.     if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0)
  2891.         goto error;
  2892.     Py_DECREF(x);
  2893. #endif
  2894. #ifdef AL_OUTPUT_DEVICE_TYPE
  2895.     x =  PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE);
  2896.     if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0)
  2897.         goto error;
  2898.     Py_DECREF(x);
  2899. #endif
  2900. #ifdef AL_OUTPUT_HRB_TYPE
  2901.     x =  PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE);
  2902.     if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0)
  2903.         goto error;
  2904.     Py_DECREF(x);
  2905. #endif
  2906. #ifdef AL_OUTPUT_PORT_TYPE
  2907.     x =  PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE);
  2908.     if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0)
  2909.         goto error;
  2910.     Py_DECREF(x);
  2911. #endif
  2912. #ifdef AL_OUTPUT_RATE
  2913.     x =  PyInt_FromLong((long) AL_OUTPUT_RATE);
  2914.     if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0)
  2915.         goto error;
  2916.     Py_DECREF(x);
  2917. #endif
  2918. #ifdef AL_PARAM_BIT
  2919.     x =  PyInt_FromLong((long) AL_PARAM_BIT);
  2920.     if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0)
  2921.         goto error;
  2922.     Py_DECREF(x);
  2923. #endif
  2924. #ifdef AL_PARAMS
  2925.     x =  PyInt_FromLong((long) AL_PARAMS);
  2926.     if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0)
  2927.         goto error;
  2928.     Py_DECREF(x);
  2929. #endif
  2930. #ifdef AL_PORT_COUNT
  2931.     x =  PyInt_FromLong((long) AL_PORT_COUNT);
  2932.     if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0)
  2933.         goto error;
  2934.     Py_DECREF(x);
  2935. #endif
  2936. #ifdef AL_PORT_TYPE
  2937.     x =  PyInt_FromLong((long) AL_PORT_TYPE);
  2938.     if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0)
  2939.         goto error;
  2940.     Py_DECREF(x);
  2941. #endif
  2942. #ifdef AL_PORTS
  2943.     x =  PyInt_FromLong((long) AL_PORTS);
  2944.     if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0)
  2945.         goto error;
  2946.     Py_DECREF(x);
  2947. #endif
  2948. #ifdef AL_PORTSTYLE_DIRECT
  2949.     x =  PyInt_FromLong((long) AL_PORTSTYLE_DIRECT);
  2950.     if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0)
  2951.         goto error;
  2952.     Py_DECREF(x);
  2953. #endif
  2954. #ifdef AL_PORTSTYLE_SERIAL
  2955.     x =  PyInt_FromLong((long) AL_PORTSTYLE_SERIAL);
  2956.     if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0)
  2957.         goto error;
  2958.     Py_DECREF(x);
  2959. #endif
  2960. #ifdef AL_PRINT_ERRORS
  2961.     x =  PyInt_FromLong((long) AL_PRINT_ERRORS);
  2962.     if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0)
  2963.         goto error;
  2964.     Py_DECREF(x);
  2965. #endif
  2966. #ifdef AL_PTR_ELEM
  2967.     x =  PyInt_FromLong((long) AL_PTR_ELEM);
  2968.     if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0)
  2969.         goto error;
  2970.     Py_DECREF(x);
  2971. #endif
  2972. #ifdef AL_RANGE_VALUE
  2973.     x =  PyInt_FromLong((long) AL_RANGE_VALUE);
  2974.     if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0)
  2975.         goto error;
  2976.     Py_DECREF(x);
  2977. #endif
  2978. #ifdef AL_RATE
  2979.     x =  PyInt_FromLong((long) AL_RATE);
  2980.     if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0)
  2981.         goto error;
  2982.     Py_DECREF(x);
  2983. #endif
  2984. #ifdef AL_RATE_11025
  2985.     x =  PyInt_FromLong((long) AL_RATE_11025);
  2986.     if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0)
  2987.         goto error;
  2988.     Py_DECREF(x);
  2989. #endif
  2990. #ifdef AL_RATE_16000
  2991.     x =  PyInt_FromLong((long) AL_RATE_16000);
  2992.     if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0)
  2993.         goto error;
  2994.     Py_DECREF(x);
  2995. #endif
  2996. #ifdef AL_RATE_22050
  2997.     x =  PyInt_FromLong((long) AL_RATE_22050);
  2998.     if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0)
  2999.         goto error;
  3000.     Py_DECREF(x);
  3001. #endif
  3002. #ifdef AL_RATE_32000
  3003.     x =  PyInt_FromLong((long) AL_RATE_32000);
  3004.     if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0)
  3005.         goto error;
  3006.     Py_DECREF(x);
  3007. #endif
  3008. #ifdef AL_RATE_44100
  3009.     x =  PyInt_FromLong((long) AL_RATE_44100);
  3010.     if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0)
  3011.         goto error;
  3012.     Py_DECREF(x);
  3013. #endif
  3014. #ifdef AL_RATE_48000
  3015.     x =  PyInt_FromLong((long) AL_RATE_48000);
  3016.     if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0)
  3017.         goto error;
  3018.     Py_DECREF(x);
  3019. #endif
  3020. #ifdef AL_RATE_8000
  3021.     x =  PyInt_FromLong((long) AL_RATE_8000);
  3022.     if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0)
  3023.         goto error;
  3024.     Py_DECREF(x);
  3025. #endif
  3026. #ifdef AL_RATE_AES_1
  3027.     x =  PyInt_FromLong((long) AL_RATE_AES_1);
  3028.     if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0)
  3029.         goto error;
  3030.     Py_DECREF(x);
  3031. #endif
  3032. #ifdef AL_RATE_AES_1s
  3033.     x =  PyInt_FromLong((long) AL_RATE_AES_1s);
  3034.     if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0)
  3035.         goto error;
  3036.     Py_DECREF(x);
  3037. #endif
  3038. #ifdef AL_RATE_AES_2
  3039.     x =  PyInt_FromLong((long) AL_RATE_AES_2);
  3040.     if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0)
  3041.         goto error;
  3042.     Py_DECREF(x);
  3043. #endif
  3044. #ifdef AL_RATE_AES_3
  3045.     x =  PyInt_FromLong((long) AL_RATE_AES_3);
  3046.     if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0)
  3047.         goto error;
  3048.     Py_DECREF(x);
  3049. #endif
  3050. #ifdef AL_RATE_AES_4
  3051.     x =  PyInt_FromLong((long) AL_RATE_AES_4);
  3052.     if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0)
  3053.         goto error;
  3054.     Py_DECREF(x);
  3055. #endif
  3056. #ifdef AL_RATE_AES_6
  3057.     x =  PyInt_FromLong((long) AL_RATE_AES_6);
  3058.     if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0)
  3059.         goto error;
  3060.     Py_DECREF(x);
  3061. #endif
  3062. #ifdef AL_RATE_FRACTION_D
  3063.     x =  PyInt_FromLong((long) AL_RATE_FRACTION_D);
  3064.     if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0)
  3065.         goto error;
  3066.     Py_DECREF(x);
  3067. #endif
  3068. #ifdef AL_RATE_FRACTION_N
  3069.     x =  PyInt_FromLong((long) AL_RATE_FRACTION_N);
  3070.     if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0)
  3071.         goto error;
  3072.     Py_DECREF(x);
  3073. #endif
  3074. #ifdef AL_RATE_INPUTRATE
  3075.     x =  PyInt_FromLong((long) AL_RATE_INPUTRATE);
  3076.     if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0)
  3077.         goto error;
  3078.     Py_DECREF(x);
  3079. #endif
  3080. #ifdef AL_RATE_NO_DIGITAL_INPUT
  3081.     x =  PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT);
  3082.     if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0)
  3083.         goto error;
  3084.     Py_DECREF(x);
  3085. #endif
  3086. #ifdef AL_RATE_UNACQUIRED
  3087.     x =  PyInt_FromLong((long) AL_RATE_UNACQUIRED);
  3088.     if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0)
  3089.         goto error;
  3090.     Py_DECREF(x);
  3091. #endif
  3092. #ifdef AL_RATE_UNDEFINED
  3093.     x =  PyInt_FromLong((long) AL_RATE_UNDEFINED);
  3094.     if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0)
  3095.         goto error;
  3096.     Py_DECREF(x);
  3097. #endif
  3098. #ifdef AL_REF_0DBV
  3099.     x =  PyInt_FromLong((long) AL_REF_0DBV);
  3100.     if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0)
  3101.         goto error;
  3102.     Py_DECREF(x);
  3103. #endif
  3104. #ifdef AL_REF_NONE
  3105.     x =  PyInt_FromLong((long) AL_REF_NONE);
  3106.     if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0)
  3107.         goto error;
  3108.     Py_DECREF(x);
  3109. #endif
  3110. #ifdef AL_RESERVED1_TYPE
  3111.     x =  PyInt_FromLong((long) AL_RESERVED1_TYPE);
  3112.     if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0)
  3113.         goto error;
  3114.     Py_DECREF(x);
  3115. #endif
  3116. #ifdef AL_RESERVED2_TYPE
  3117.     x =  PyInt_FromLong((long) AL_RESERVED2_TYPE);
  3118.     if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0)
  3119.         goto error;
  3120.     Py_DECREF(x);
  3121. #endif
  3122. #ifdef AL_RESERVED3_TYPE
  3123.     x =  PyInt_FromLong((long) AL_RESERVED3_TYPE);
  3124.     if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0)
  3125.         goto error;
  3126.     Py_DECREF(x);
  3127. #endif
  3128. #ifdef AL_RESERVED4_TYPE
  3129.     x =  PyInt_FromLong((long) AL_RESERVED4_TYPE);
  3130.     if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0)
  3131.         goto error;
  3132.     Py_DECREF(x);
  3133. #endif
  3134. #ifdef AL_RESOURCE
  3135.     x =  PyInt_FromLong((long) AL_RESOURCE);
  3136.     if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0)
  3137.         goto error;
  3138.     Py_DECREF(x);
  3139. #endif
  3140. #ifdef AL_RESOURCE_ELEM
  3141.     x =  PyInt_FromLong((long) AL_RESOURCE_ELEM);
  3142.     if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0)
  3143.         goto error;
  3144.     Py_DECREF(x);
  3145. #endif
  3146. #ifdef AL_RESOURCE_TYPE
  3147.     x =  PyInt_FromLong((long) AL_RESOURCE_TYPE);
  3148.     if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0)
  3149.         goto error;
  3150.     Py_DECREF(x);
  3151. #endif
  3152. #ifdef AL_RIGHT_INPUT_ATTEN
  3153.     x =  PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN);
  3154.     if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0)
  3155.         goto error;
  3156.     Py_DECREF(x);
  3157. #endif
  3158. #ifdef AL_RIGHT_MONITOR_ATTEN
  3159.     x =  PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN);
  3160.     if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0)
  3161.         goto error;
  3162.     Py_DECREF(x);
  3163. #endif
  3164. #ifdef AL_RIGHT_SPEAKER_GAIN
  3165.     x =  PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN);
  3166.     if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0)
  3167.         goto error;
  3168.     Py_DECREF(x);
  3169. #endif
  3170. #ifdef AL_RIGHT1_INPUT_ATTEN
  3171.     x =  PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN);
  3172.     if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0)
  3173.         goto error;
  3174.     Py_DECREF(x);
  3175. #endif
  3176. #ifdef AL_RIGHT2_INPUT_ATTEN
  3177.     x =  PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN);
  3178.     if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0)
  3179.         goto error;
  3180.     Py_DECREF(x);
  3181. #endif
  3182. #ifdef AL_SAMPFMT_DOUBLE
  3183.     x =  PyInt_FromLong((long) AL_SAMPFMT_DOUBLE);
  3184.     if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0)
  3185.         goto error;
  3186.     Py_DECREF(x);
  3187. #endif
  3188. #ifdef AL_SAMPFMT_FLOAT
  3189.     x =  PyInt_FromLong((long) AL_SAMPFMT_FLOAT);
  3190.     if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0)
  3191.         goto error;
  3192.     Py_DECREF(x);
  3193. #endif
  3194. #ifdef AL_SAMPFMT_TWOSCOMP
  3195.     x =  PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP);
  3196.     if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0)
  3197.         goto error;
  3198.     Py_DECREF(x);
  3199. #endif
  3200. #ifdef AL_SAMPLE_16
  3201.     x =  PyInt_FromLong((long) AL_SAMPLE_16);
  3202.     if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0)
  3203.         goto error;
  3204.     Py_DECREF(x);
  3205. #endif
  3206. #ifdef AL_SAMPLE_24
  3207.     x =  PyInt_FromLong((long) AL_SAMPLE_24);
  3208.     if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0)
  3209.         goto error;
  3210.     Py_DECREF(x);
  3211. #endif
  3212. #ifdef AL_SAMPLE_8
  3213.     x =  PyInt_FromLong((long) AL_SAMPLE_8);
  3214.     if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0)
  3215.         goto error;
  3216.     Py_DECREF(x);
  3217. #endif
  3218. #ifdef AL_SCALAR_VAL
  3219.     x =  PyInt_FromLong((long) AL_SCALAR_VAL);
  3220.     if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0)
  3221.         goto error;
  3222.     Py_DECREF(x);
  3223. #endif
  3224. #ifdef AL_SET_VAL
  3225.     x =  PyInt_FromLong((long) AL_SET_VAL);
  3226.     if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0)
  3227.         goto error;
  3228.     Py_DECREF(x);
  3229. #endif
  3230. #ifdef AL_SHORT_NAME
  3231.     x =  PyInt_FromLong((long) AL_SHORT_NAME);
  3232.     if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0)
  3233.         goto error;
  3234.     Py_DECREF(x);
  3235. #endif
  3236. #ifdef AL_SOURCE
  3237.     x =  PyInt_FromLong((long) AL_SOURCE);
  3238.     if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0)
  3239.         goto error;
  3240.     Py_DECREF(x);
  3241. #endif
  3242. #ifdef AL_SPEAKER_IF_TYPE
  3243.     x =  PyInt_FromLong((long) AL_SPEAKER_IF_TYPE);
  3244.     if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0)
  3245.         goto error;
  3246.     Py_DECREF(x);
  3247. #endif
  3248. #ifdef AL_SPEAKER_MUTE_CTL
  3249.     x =  PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL);
  3250.     if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0)
  3251.         goto error;
  3252.     Py_DECREF(x);
  3253. #endif
  3254. #ifdef AL_SPEAKER_MUTE_OFF
  3255.     x =  PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF);
  3256.     if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0)
  3257.         goto error;
  3258.     Py_DECREF(x);
  3259. #endif
  3260. #ifdef AL_SPEAKER_MUTE_ON
  3261.     x =  PyInt_FromLong((long) AL_SPEAKER_MUTE_ON);
  3262.     if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0)
  3263.         goto error;
  3264.     Py_DECREF(x);
  3265. #endif
  3266. #ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE
  3267.     x =  PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE);
  3268.     if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0)
  3269.         goto error;
  3270.     Py_DECREF(x);
  3271. #endif
  3272. #ifdef AL_STEREO
  3273.     x =  PyInt_FromLong((long) AL_STEREO);
  3274.     if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0)
  3275.         goto error;
  3276.     Py_DECREF(x);
  3277. #endif
  3278. #ifdef AL_STRING_VAL
  3279.     x =  PyInt_FromLong((long) AL_STRING_VAL);
  3280.     if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0)
  3281.         goto error;
  3282.     Py_DECREF(x);
  3283. #endif
  3284. #ifdef AL_SUBSYSTEM
  3285.     x =  PyInt_FromLong((long) AL_SUBSYSTEM);
  3286.     if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0)
  3287.         goto error;
  3288.     Py_DECREF(x);
  3289. #endif
  3290. #ifdef AL_SUBSYSTEM_TYPE
  3291.     x =  PyInt_FromLong((long) AL_SUBSYSTEM_TYPE);
  3292.     if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0)
  3293.         goto error;
  3294.     Py_DECREF(x);
  3295. #endif
  3296. #ifdef AL_SYNC_INPUT_TO_AES
  3297.     x =  PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES);
  3298.     if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0)
  3299.         goto error;
  3300.     Py_DECREF(x);
  3301. #endif
  3302. #ifdef AL_SYNC_OUTPUT_TO_AES
  3303.     x =  PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES);
  3304.     if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0)
  3305.         goto error;
  3306.     Py_DECREF(x);
  3307. #endif
  3308. #ifdef AL_SYSTEM
  3309.     x =  PyInt_FromLong((long) AL_SYSTEM);
  3310.     if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0)
  3311.         goto error;
  3312.     Py_DECREF(x);
  3313. #endif
  3314. #ifdef AL_SYSTEM_TYPE
  3315.     x =  PyInt_FromLong((long) AL_SYSTEM_TYPE);
  3316.     if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0)
  3317.         goto error;
  3318.     Py_DECREF(x);
  3319. #endif
  3320. #ifdef AL_TEST_IF_TYPE
  3321.     x =  PyInt_FromLong((long) AL_TEST_IF_TYPE);
  3322.     if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0)
  3323.         goto error;
  3324.     Py_DECREF(x);
  3325. #endif
  3326. #ifdef AL_TYPE
  3327.     x =  PyInt_FromLong((long) AL_TYPE);
  3328.     if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0)
  3329.         goto error;
  3330.     Py_DECREF(x);
  3331. #endif
  3332. #ifdef AL_TYPE_BIT
  3333.     x =  PyInt_FromLong((long) AL_TYPE_BIT);
  3334.     if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0)
  3335.         goto error;
  3336.     Py_DECREF(x);
  3337. #endif
  3338. #ifdef AL_UNUSED_COUNT
  3339.     x =  PyInt_FromLong((long) AL_UNUSED_COUNT);
  3340.     if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0)
  3341.         goto error;
  3342.     Py_DECREF(x);
  3343. #endif
  3344. #ifdef AL_UNUSED_PORTS
  3345.     x =  PyInt_FromLong((long) AL_UNUSED_PORTS);
  3346.     if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0)
  3347.         goto error;
  3348.     Py_DECREF(x);
  3349. #endif
  3350. #ifdef AL_VARIABLE_MCLK_TYPE
  3351.     x =  PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE);
  3352.     if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0)
  3353.         goto error;
  3354.     Py_DECREF(x);
  3355. #endif
  3356. #ifdef AL_VECTOR_VAL
  3357.     x =  PyInt_FromLong((long) AL_VECTOR_VAL);
  3358.     if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0)
  3359.         goto error;
  3360.     Py_DECREF(x);
  3361. #endif
  3362. #ifdef AL_VIDEO_MCLK_TYPE
  3363.     x =  PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE);
  3364.     if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0)
  3365.         goto error;
  3366.     Py_DECREF(x);
  3367. #endif
  3368. #ifdef AL_WORDSIZE
  3369.     x =  PyInt_FromLong((long) AL_WORDSIZE);
  3370.     if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0)
  3371.         goto error;
  3372.     Py_DECREF(x);
  3373. #endif
  3374.  
  3375. #ifdef AL_NO_ELEM        /* IRIX 6 */
  3376.     (void) alSetErrorHandler(ErrorHandler);
  3377. #endif /* AL_NO_ELEM */
  3378. #ifdef OLD_INTERFACE
  3379.     (void) ALseterrorhandler(ErrorHandler);
  3380. #endif /* OLD_INTERFACE */
  3381.     
  3382.     /* Check for errors */
  3383.     if (PyErr_Occurred()) {
  3384.       error:
  3385.         Py_FatalError("can't initialize module al");
  3386.     }
  3387. }
  3388.